Master Vue Router - Navigation, Guards, Lazy Loading, Meta Fields, History Modes
Configures Vue Router with navigation guards, lazy loading, and meta fields for SPA/SSR apps. Use when building multi-page Vue applications requiring authentication flows, dynamic routes, or performance optimization.
/plugin marketplace add pluginagentmarketplace/custom-plugin-vue/plugin install vue-assistant@pluginagentmarketplace-vueThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyProduction-grade skill for mastering Vue Router and building robust navigation systems.
Single Responsibility: Teach Vue Router configuration, navigation patterns, route guards, lazy loading, and advanced routing techniques.
interface VueRouterParams {
topic: 'config' | 'guards' | 'lazy-loading' | 'meta' | 'navigation' | 'all';
level: 'beginner' | 'intermediate' | 'advanced';
context?: {
auth_required?: boolean;
app_type?: 'spa' | 'ssr';
};
}
Prerequisites: vue-fundamentals
Duration: 2 hours
Outcome: Configure Vue Router
| Topic | Concept | Exercise |
|---|---|---|
| Installation | Vue Router setup | Basic config |
| Routes array | Route definitions | Multi-page app |
| History modes | Hash vs HTML5 | Production setup |
| Router-view | Outlet component | Layout system |
| Router-link | Navigation links | Navigation menu |
Prerequisites: Module 1
Duration: 2-3 hours
Outcome: Build complex route structures
| Pattern | Example | Exercise |
|---|---|---|
| Dynamic params | /user/:id | User profile |
| Optional params | /user/:id? | Optional filters |
| Catch-all | /:pathMatch(.*)* | 404 page |
| Nested routes | /dashboard/settings | Admin layout |
| Named views | Multiple outlets | Dashboard widgets |
Prerequisites: Modules 1-2
Duration: 3-4 hours
Outcome: Secure routes with guards
| Guard Type | Scope | Use Case |
|---|---|---|
| beforeEach | Global | Auth check |
| beforeEnter | Per-route | Role check |
| beforeRouteEnter | Component | Data prefetch |
| beforeRouteUpdate | Component | Param change |
| beforeRouteLeave | Component | Unsaved changes |
| afterEach | Global | Analytics |
Guard Composition:
router.beforeEach(async (to, from) => {
// Auth check
if (to.meta.requiresAuth && !isAuthenticated()) {
return { name: 'Login', query: { redirect: to.fullPath } }
}
// Role check
if (to.meta.roles && !hasRole(to.meta.roles)) {
return { name: 'Unauthorized' }
}
return true
})
Prerequisites: Module 3
Duration: 2 hours
Outcome: Optimize route loading
| Technique | Implementation | Benefit |
|---|---|---|
| Basic lazy | () => import() | Smaller bundles |
| Named chunks | webpackChunkName | Grouped loading |
| Prefetching | router.afterEach | Faster navigation |
| Loading states | Async components | Better UX |
Prerequisites: Modules 1-4
Duration: 3 hours
Outcome: Expert routing techniques
| Pattern | Use Case | Exercise |
|---|---|---|
| Route meta | Page metadata | SEO, auth, layout |
| Scroll behavior | Scroll position | Saved positions |
| Transitions | Page animations | Enter/leave effects |
| Route modules | Large apps | Feature-based routes |
const skillConfig = {
maxAttempts: 3,
backoffMs: [1000, 2000, 4000],
onFailure: 'provide_simpler_route'
}
tracking:
- event: route_configured
data: [route_count, guards_count]
- event: navigation_pattern_learned
data: [pattern_name, complexity]
- event: skill_completed
data: [routes_built, auth_implemented]
| Issue | Cause | Solution |
|---|---|---|
| Route not matching | Wrong path order | Specific before generic |
| Guard infinite loop | Guard → same route | Check target route |
| Lazy load fails | Wrong import path | Verify file exists |
| Params undefined | Missing props: true | Enable props |
import { describe, it, expect, beforeEach } from 'vitest'
import { createRouter, createWebHistory } from 'vue-router'
import { routes } from './routes'
describe('Router', () => {
let router: Router
beforeEach(() => {
router = createRouter({
history: createWebHistory(),
routes
})
})
it('redirects to login when not authenticated', async () => {
await router.push('/dashboard')
expect(router.currentRoute.value.name).toBe('Login')
})
it('allows access to public routes', async () => {
await router.push('/about')
expect(router.currentRoute.value.name).toBe('About')
})
})
Skill("vue-router")
vue-fundamentals - Prerequisitevue-pinia - Auth state for guardsvue-nuxt - File-based routing alternativeThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.