Skip to main content
skill CX Codex

vue-router-skilld — Claude Code skill: what it does, how to install

vue-router-skilld guides AI coding agents through [email protected] conventions. Covers typed routes, experimental data loaders, and file-based routing without deprecated patterns.

MIT 324 installs ★ 186 updated 2026-10-10

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add skilld-dev/vue-ecosystem-skills --skill vue-router-skilld -a claude-code
Open on GitHub

What vue-router-skilld does

The skill injects core patterns for [email protected] under vue ^3.5.34 || ^4.0.0. It maps imports across Vite, Unplugin, and auto-routes modules while flagging deprecated entry points like vue-router/auto.

It enforces modern routing rules. Navigation guards must return values instead of invoking next(), which triggers deprecation warnings. It also requires router.currentRoute.value lookups and enforces bundling order: VueRouter() must run before Vue() in vite.config.ts.

Experimental data loaders rely on defineBasicLoader and redirect via reroute(to). Note that vue-router/experimental is ESM-only and fails in CommonJS builds.

What it helps with

  • migrate navigation guards away from deprecated next() callbacks
  • configure vue-router/vite ahead of @vitejs/plugin-vue
  • set up typed routes and parameter parsers with RouteNamedMap
  • implement data loaders with defineBasicLoader and reroute

Example prompts for the agent

  • Set up file-based routing in vite.config.ts using vue-router/vite
  • Refactor our beforeEach navigation guards to return values instead of calling next
  • Create a typed data loader for user profiles using vue-router/experimental

How to install vue-router-skilld

1Skills CLI (Vercel)

npx skills add skilld-dev/vue-ecosystem-skills --skill vue-router-skilld -a claude-code

2Manually: put the files in place

~/.claude/skills/vue-router-skilld/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/vue-router-skilld/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about vue-router-skilld

How to install vue-router-skilld in Claude Code?

Run npx skills add skilld-dev/vue-ecosystem-skills --skill vue-router-skilld -a claude-code. The file will be placed in ~/.claude/skills/vue-router-skilld/SKILL.md.

What Vue versions are supported?

The skill targets [email protected] with peer dependencies vue ^3.5.34 || ^4.0.0. Optional peers include vite ^7.3.0 || ^8.0.0 and pinia ^3.0.4 || ^4.0.2.

Can I use vue-router/experimental in CommonJS projects?

No. Starting with v5.1.0, vue-router/experimental is ESM-only and will not work in CJS builds.

Source text

SKILL.md · MIT
---
name: vue-router-skilld
description: 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.
license: MIT
---

# vuejs/router `[email protected]`

Prepared source: `[email protected]`, 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/experimental` in CJS builds — ESM-only since v5.1.0 (https://github.com/vuejs/router/releases/tag/v5.1.0).

## Quick start (classic routes)

```ts
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)

```ts
// 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
})
```

```ts
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](./references/file-based-routing.md).

## Core rules

- Return values from navigation guards, never call `next()`. `next` is 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).
  ```ts
  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.currentRoute` is a `ShallowRef<RouteLocationNormalizedLoaded>` — read it as `router.currentRoute.value` (dist/index-D7ja2BKs.d.ts:1433).
- `router.onReady()` does not exist (removed in v4); use `await router.isReady()`.
- `scrollBehavior` returns `{ top, left }` (v4 renamed `x`/`y` to `left`/`top`).
- Detect failed navigations: `const failure = await router.push(...)`; check with `isNavigationFailure(failure, NavigationFailureType.aborted)`.
- `route.meta` merges non-recursively from all matched records; read `to.meta.requiresAuth` directly instead of scanning `to.matched`. Type `meta` via `RouteMeta` module augmentation.
- Use `router.beforeResolve` (not `beforeEach`) 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: true` or `props: route => ({ ... })`; pass query values this way to keep components testable.
- Watch narrow sources (`() => route.params.id`), never the whole `route` object.

Full core API notes: [references/core-api.md](./references/core-api.md).

## Typed routes

Enable by using the file-based routing plugin (types are generated automatically), or augment manually:

```ts
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](./references/typed-routes.md).

## Data loaders (experimental)

```ts
// 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](./references/data-loaders.md).

## Version notes (5.0.x → 5.3.1)

- v5.0.7: `RouteNamedMap` is wired through the generated `typed-router.d.ts` (https://github.com/vuejs/router/releases/tag/v5.0.7); param parser folders gained `include`/`exclude`.
- v5.1.0: typed `definePage` `params.path`, `defineParamParserRaw`, strict default typing, `TypesConfig` global `Router` override, 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.scrollRestoration` says so; duplicate `definePage()` reported instead of crashing; `EditableTreeNode.name` accepts `false` to unset (https://github.com/vuejs/router/releases/tag/v5.3.0).
- v5.3.1: fixes `isActive` with 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/migration.md).

## References

- [core-api.md](./references/core-api.md) — router creation, histories, guards, failures, scroll, RouterLink/RouterView.
- [file-based-routing.md](./references/file-based-routing.md) — plugin setup, file naming, `definePage`, `<route>` blocks, `extendRoute`, options.
- [typed-routes.md](./references/typed-routes.md) — `TypesConfig`, generated types, param parsers, `experimental_createRouter`.
- [data-loaders.md](./references/data-loaders.md) — `defineBasicLoader`, `defineColadaLoader`, `reroute`, lazy loaders, SSR notes.
- [migration.md](./references/migration.md) — v3→v4 and v4→v5 changes, deprecations in the v5 line.

© skilld-dev · MIT · skilld-dev/vue-ecosystem-skills

Similar skills

All skills for Frontend and UI →

From the same set32

The whole set →
vue-i18n-skilld vue-i18n-skilld — a skill that steers your agent through vue-i18n code in Vue 3: message syntax, pluralization, date and number formats, v12 migration. CX Codex +1 438installs vue-skilld vue-skilld guides coding agents through Vue 3.6 development. Useful when creating composables, setting up Vapor Mode, or migrating code from Vue 3.4 and 3.5. CX Codex +1 434installs vuetify-skilld vuetify-skilld directs AI assistants on configuring and debugging Vuetify 4.x with Vue 3. Helps handle tree-shaking, Vite integration, and v3 to v4 migration. CX Codex +1 421installs pinia-skilld pinia-skilld — a skill that feeds your coding agent the correct Pinia 4.x APIs: stores, getters, actions, SSR hydration, testing and v2/v3 migration notes. CX Codex +1 349installs pinia-colada-skilld pinia-colada-skilld gives coding assistants patterns and rules for @pinia/colada in Vue. Helps write queries, handle mutations, invalidate cache, and set up SSR. CX Codex +1 240installs tanstack-vue-query-skilld tanstack-vue-query-skilld guides AI assistants on @tanstack/vue-query v5 conventions. It prevents reactivity bugs with query keys and SSR setup in Vue projects. CX Codex +1 223installs vueuse-core-skilld vueuse-core-skilld — a skill with the full @vueuse/core 15.0.0 API: new composables, v14 migration rules, deprecated functions and environment requirements. CX Codex +1 219installs vee-validate-skilld vee-validate-skilld — a skill for writing, reviewing, and debugging Vue 3 forms with vee-validate 4.15.x. Covers Composition API, validation schema patterns, typed-schema integration, version-specific changes since 4.9, and common pitfalls. CX Codex +1 188installs

Project sponsors

Companies that keep this analytics open