vue-router-best-practices — Claude Code skill: routing and lifecycle
Skill teaches AI coders Vue Router 4 patterns: navigation guards, route params handling, and component lifecycle synchronization. Prevents infinite redirects, memory leaks, and data desync.
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a claude-codeWhat vue-router-best-practices does
The skill covers navigation guard patterns (beforeRouteEnter, beforeRouteLeave), proper async/await usage in guards, and transitions between routes with different params. It addresses common mistakes: forgotten await in guards, use of deprecated next() function, event listeners persisting after component unmount.
Once installed, the skill provides Claude Code, Cursor, or another supported editor with recommendations on Vue Router 4 in production, patterns that trigger infinite redirect loops, and ways to sync component data when route params change.
What it helps with
- Prevent infinite redirect loops in navigation guards
- Sync component data when route params change
- Clean up event listeners before component unmount
- Use async/await correctly in beforeRouteEnter and other guards
- Migrate from deprecated next() to modern Vue Router 4 syntax
Example prompts for the agent
- Write a navigation guard that loads data before entering a route and handles network errors
- Show how to update a component when route params change but the route itself stays the same
- Help set up cleanup for event listeners when moving to a different route
How to install vue-router-best-practices
1Skills CLI (Vercel)
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/vue-router-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/vue-router-best-practices/
1Skills CLI (Vercel)
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a codex2Manually: put the files in place
.agents/skills/vue-router-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a cursor2Manually: put the files in place
.cursor/skills/vue-router-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install vuejs-ai/skills vue-router-best-practices2Manually: put the files in place
.github/skills/vue-router-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/vuejs-ai/skills --path skills/vue-router-best-practicesManually: put the files in place
.devin/skills/vue-router-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add vuejs-ai/skills --skill vue-router-best-practices -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set7
The whole set →Similar
Questions about vue-router-best-practices
How do I install vue-router-best-practices in Claude Code?
Run npx skills add vuejs-ai/skills --skill vue-router-best-practices -a claude-code, then open ~/.claude/skills/vue-router-best-practices/SKILL.md. Other editors use different commands (see Cursor, Codex, or GitHub Copilot in the list).
What does this skill do?
It teaches AI coders Vue Router 4 rules: how to write navigation guards, work with route params, sync component state, and avoid memory leaks.
Does the skill work with all editors?
Yes, it supports Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI, and OpenCode. Each editor requires its own install command.
Source text
SKILL.md · MIT
--- name: vue-router-best-practices description: "Vue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions." version: 1.0.0 license: MIT author: github.com/vuejs-ai --- Vue Router best practices, common gotchas, and navigation patterns. ### Navigation Guards - Navigating between same route with different params → See [router-beforeenter-no-param-trigger](reference/router-beforeenter-no-param-trigger.md) - Accessing component instance in beforeRouteEnter guard → See [router-beforerouteenter-no-this](reference/router-beforerouteenter-no-this.md) - Navigation guard making API calls without awaiting → See [router-guard-async-await-pattern](reference/router-guard-async-await-pattern.md) - Users trapped in infinite redirect loops → See [router-navigation-guard-infinite-loop](reference/router-navigation-guard-infinite-loop.md) - Navigation guard using deprecated next() function → See [router-navigation-guard-next-deprecated](reference/router-navigation-guard-next-deprecated.md) ### Route Lifecycle - Stale data when navigating between same route → See [router-param-change-no-lifecycle](reference/router-param-change-no-lifecycle.md) - Event listeners persisting after component unmounts → See [router-simple-routing-cleanup](reference/router-simple-routing-cleanup.md) ### Setup - Building production single-page application → See [router-use-vue-router-for-production](reference/router-use-vue-router-for-production.md)
© github.com/vuejs-ai · MIT · vuejs-ai/skills