vue-router-best-practices

Implement Vue Router navigation guards with safe async patterns and loop prevention.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/emilneuraz-ai/neuraz-web --skill vue-router-best-practices-emilneuraz-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-router-best-practices
Source: https://github.com/emilneuraz-ai/neuraz-web/tree/main/.agents/skills/.agents/skills/vue-router-best-practices
Command: npx skills add https://github.com/emilneuraz-ai/neuraz-web --skill vue-router-best-practices-emilneuraz-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Developers often encounter gotchas in Vue Router navigation guards, route params, and lifecycle hooks, leading to bugs and hard-to-trace flows.

Core Features & Use Cases

  • Per-route, in-component, and global guard patterns to guard navigation and data loading
  • Handling route param changes with onBeforeRouteUpdate and route guards to avoid stale data
  • Strategies to prevent infinite redirects, param-based access issues, and lifecycle pitfalls in production apps

Quick Start

Review the reference topics to implement robust Vue Router guards in your app.

Frequently Asked Questions about vue-router-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent infinite redirect loops in Vue Router navigation guards?

Prevent infinite redirect loops in Vue Router navigation guards by applying safe async patterns and structured guard logic to avoid cyclic routing conditions. Implement global, per-route, and in-component guards to break cycles.

What is the best way to handle Vue Router route param changes without stale data?

Handle Vue Router route param changes by using onBeforeRouteUpdate and in-component guards to trigger data reloading. This ensures your component refreshes data properly when navigating between dynamic routes with different parameters.

How does Vue Router beforeRouteUpdate interact with component lifecycle hooks?

Vue Router beforeRouteUpdate fires before component updates when route params change, allowing you to manage data fetching and avoid lifecycle pitfalls without remounting the component entirely during navigation.

When should I use global beforeEach versus per-route beforeEnter guards in Vue Router?

Use Vue Router global beforeEach guards for application-wide access control and per-route beforeEnter guards for route-specific data loading. Combining them prevents param-based access issues and ensures robust navigation flows.

Why does my Vue Router guard not trigger on navigation?

Vue Router guards may not trigger if route definitions, guard registration, or async patterns are incorrectly configured. Review global, per-route, and in-component guard implementations to ensure proper hook registration.