vue-router-skilld
Skill184 starsChanged 37 days agoMITView on GitHub
ALWAYS use when writing code that imports "vue-router", "vue-router/vite", "vue-router/auto-routes", or "vue-router/experimental". Consult for debugging, best practices, or modifying vue-router, vue router, router, file-based routing, typed routes, data loaders.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- lecluse-net/galaristheir own version, first seen Oct 30, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- lecluse-net/galaris★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- floating-ui-vue-skilldSkill
- formkit-core-skilldSkill
- motion-v-skilldSkill
- pinia-colada-skilldSkill
- pinia-skilldSkill
- primevue-skilldSkill
- quasar-skilldSkill
- reka-ui-skilldSkill
- shadcn-vue-skilldSkill
- slidev-cli-skilldSkill
- tanstack-ai-vue-skilldSkill
- tanstack-vue-form-skilldSkill
- tanstack-vue-query-skilldSkill
- tanstack-vue-router-skilldSkill
- tanstack-vue-store-skilldSkill
- tanstack-vue-table-skilldSkill
- tanstack-vue-virtual-skilldSkill
- tresjs-core-skilldSkill
- unhead-vue-skilldSkill
- unovis-ts-skilldSkill
- unovis-vue-skilldSkill
- vee-validate-skilldSkill
- vitepress-skilldSkill
- vue-data-ui-skilldSkill
- vue-i18n-skilldSkill
- vue-skilldSkill
- vue-test-utils-skilldSkill
- vuetify-skilldSkill
- vueuse-components-skilldSkill
- vueuse-core-skilldSkill
- vueuse-integrations-skilldSkill
- vueuse-math-skilldSkill
- vueuse-motion-skilldSkill
- vueuse-shared-skilldSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 85
Use router.beforeResolve (not beforeEach) for work that needs async components resolved.
- Very specific: line 86
Use inject() inside guards to reach Pinia stores (supported since Vue 3.3).
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
vuejs/router vue-router@5.3.1
Prepared source: vue-router@5.3.1, ESM package ("type": "module", package.json:2,20).
Peers: vue ^3.5.34 || ^4.0.0; optional vite ^7.3.0 || ^8.0.0, pinia ^3.0.4 || ^4.0.2, @pinia/colada >=0.21.2 (package.json:173-193).
Docs: https://router.vuejs.org
Import map
| Import | Use for |
vue-router | createRouter, createWebHistory, createWebHashHistory, createMemoryHistory, RouterLink, RouterView, useRouter, useRoute, useLink, onBeforeRouteLeave, onBeforeRouteUpdate, isNavigationFailure, NavigationFailureType, START_LOCATION, parseQuery, stringifyQuery (dist/vue-router.d.ts:6) |
vue-router/vite | Vite plugin, file-based routing (package.json:104) |
vue-router/unplugin/{vite,webpack,rollup,esbuild,rolldown} | same plugin for other bundlers (dist/unplugin/) |
vue-router/unplugin | VueRouterAutoImports, createRoutesContext, EditableTreeNode, plugin Options (dist/unplugin/index.d.mts:62) |
vue-router/auto-routes | generated routes array + handleHotUpdate(router) (vue-router-auto-routes.d.mts:6,28) |
vue-router/auto-resolver | generated resolver for experimental_createRouter + handleHotUpdate (vue-router-auto-resolver.d.mts:15,21) |
vue-router/experimental | data loaders, reroute, miss, definePage, defineParamParser, PARAM_PARSER_INT/PARAM_PARSER_BOOL, experimental_createRouter, useIsDataLoading (dist/experimental/index.d.ts:7) |
vue-router/experimental/pinia-colada | defineColadaLoader (package.json:77) |
vue-router/volar/sfc-route-blocks, vue-router/volar/sfc-typed-router | Volar plugins: <route> blocks, per-file typed useRoute() (package.json:115-121) |
Avoid:
vue-router/auto— deprecated, will be removed (vue-router-auto.d.ts:1).vue-router/experimentalin CJS builds — ESM-only since v5.1.0 (https://github.com/vuejs/router/releases/tag/v5.1.0).
Quick start (classic routes)
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', component: () => import('./pages/Home.vue') },
{ path: '/users/:id', component: () => import('./pages/User.vue'), props: true },
],
})
app.use(router)In components: useRoute() / useRouter() from vue-router; <RouterLink to="..."> and <RouterView> are globally registered by app.use(router).
Quick start (file-based routing)
// vite.config.ts
import VueRouter from 'vue-router/vite'
import Vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [VueRouter(), Vue()], // Vue plugin MUST come after VueRouter
})import { createRouter, createWebHistory } from 'vue-router'
import { routes, handleHotUpdate } from 'vue-router/auto-routes'
const router = createRouter({ history: createWebHistory(), routes })
if (import.meta.hot) handleHotUpdate(router)Pages live in src/pages by default. Start the dev server once to generate typed-router.d.ts, add it to tsconfig.json include with "moduleResolution": "Bundler". Details, naming conventions, and plugin options: references/file-based-routing.md.
Core rules
- Return values from navigation guards, never call
next().nextis deprecated (runtime warning since v5.0.3) and will be removed (dist/index-D7ja2BKs.d.ts:362-393, https://github.com/vuejs/router/releases/tag/v5.0.3).router.beforeEach(to => { if (to.meta.requiresAuth && !isAuthenticated) return { name: 'login' } // return nothing, true, false, or a route location }) - In data loaders, redirect with
reroute(to);new NavigationResult(to)is deprecated and logs a warning (dist/experimental/index.js:1106-1111). router.currentRouteis aShallowRef<RouteLocationNormalizedLoaded>— read it asrouter.currentRoute.value(dist/index-D7ja2BKs.d.ts:1433).router.onReady()does not exist (removed in v4); useawait router.isReady().scrollBehaviorreturns{ top, left }(v4 renamedx/ytoleft/top).- Detect failed navigations:
const failure = await router.push(...); check withisNavigationFailure(failure, NavigationFailureType.aborted). route.metamerges non-recursively from all matched records; readto.meta.requiresAuthdirectly instead of scanningto.matched. TypemetaviaRouteMetamodule augmentation.- Use
router.beforeResolve(notbeforeEach) for work that needs async components resolved. - Use
inject()inside guards to reach Pinia stores (supported since Vue 3.3). - Decouple components from the router with route
props: trueorprops: route => ({ ... }); pass query values this way to keep components testable. - Watch narrow sources (
() => route.params.id), never the wholerouteobject.
Full core API notes: references/core-api.md.
Typed routes
Enable by using the file-based routing plugin (types are generated automatically), or augment manually:
declare module 'vue-router' {
interface TypesConfig {
RouteNamedMap: RouteNamedMap
}
}Typed push('/users/:id', { params: { id: 42 } }), typed useRoute(), per-file typing via Volar plugin vue-router/volar/sfc-typed-router. Param parsers (int, bool, custom in src/params/) give typed, validated params; definePage({ params: { query: { page: { parser: 'int', default: 1 } } } }) declares query params. Details: references/typed-routes.md.
Data loaders (experimental)
// src/pages/users/[id].vue
import { defineBasicLoader } from 'vue-router/experimental'
import { reroute } from 'vue-router/experimental'
export const useUserData = defineBasicLoader(async (to) => {
if (!to.params.id) reroute('/') // reroute throws: stops the loader immediately
return fetchUser(to.params.id)
})Install DataLoaderPlugin before the router: app.use(DataLoaderPlugin, { router }). Non-blocking loaders: defineBasicLoader(loader, { lazy: true }); errors then land in error, not in router.onError. Details: references/data-loaders.md.
Version notes (5.0.x → 5.3.1)
- v5.0.7:
RouteNamedMapis wired through the generatedtyped-router.d.ts(https://github.com/vuejs/router/releases/tag/v5.0.7); param parser folders gainedinclude/exclude. - v5.1.0: typed
definePageparams.path,defineParamParserRaw, strict default typing,TypesConfigglobalRouteroverride, experimental export is ESM-only (https://github.com/vuejs/router/releases/tag/v5.1.0). - v5.2.0: added diagnostics for common mistakes; allows pinia 4 (https://github.com/vuejs/router/releases/tag/v5.2.0).
- v5.3.0: scroll skips when
history.scrollRestorationsays so; duplicatedefinePage()reported instead of crashing;EditableTreeNode.nameacceptsfalseto unset (https://github.com/vuejs/router/releases/tag/v5.3.0). - v5.3.1: fixes
isActivewith non-string params (https://github.com/vuejs/router/releases/tag/v5.3.1).
Migration from v3/v4, or from unplugin-vue-router: references/migration.md.
References
- core-api.md — router creation, histories, guards, failures, scroll, RouterLink/RouterView.
- file-based-routing.md — plugin setup, file naming,
definePage,<route>blocks,extendRoute, options. - typed-routes.md —
TypesConfig, generated types, param parsers,experimental_createRouter. - data-loaders.md —
defineBasicLoader,defineColadaLoader,reroute, lazy loaders, SSR notes. - migration.md — v3→v4 and v4→v5 changes, deprecations in the v5 line.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

