MCPInstall

tanstack-vue-router-skilld

Use when writing, debugging, or refactoring code that imports @tanstack/vue-router (TanStack Router for Vue). Covers setup, file-based and code-based routes, composables returning Ref, Link, loaders, search params, SSR, and v1.170.x deprecations.

Installs
100
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/skilld-dev/vue-ecosystem-skills --skill tanstack-vue-router-skilld
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads tanstack-vue-router-skilld automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

@tanstack/vue-router

Type-safe router for Vue. Prepared source: version 1.170.35 (package.json:3).

  • Requires vue >= 3.3.0 (peer), Node >= 20.19 (package.json:59-88)
  • Runtime deps: @tanstack/router-core@1.171.32, @tanstack/history@1.162.4, @tanstack/vue-store@^0.11.0
  • ESM-only ("type": "module"), no main/CJS entry
  • Entry points: @tanstack/vue-router, @tanstack/vue-router/ssr/server, @tanstack/vue-router/ssr/client (package.json:29-50)

Docs: https://tanstack.com/router (framework pages verified at /router/latest/docs/framework/vue/...)

Hard rules

  1. Most composables return Ref<T> — use .value in script; templates auto-unwrap. useRouter(), useNavigate(), useLinkProps(), useAwaited() do NOT return refs. Full table in references/composables.md.
  2. Never cast or annotate inferred route/router types. Types come from the route tree and the Register declaration.
  3. Register the router for type safety — without this, Link/useNavigate/useSearch accept any string:
declare module '@tanstack/vue-router' {
  interface Register {
    router: typeof router
  }
}
  1. Not vue-router. Never import useRoute/useRouter from vue-router, never use <router-view>/<router-link>.
  2. beforeLoad/loader are plain async functions. Vue composables (ref, computed, lifecycle hooks) cannot run inside them. Pass state through router context.
  3. Route options accept Vue SFCs: component, errorComponent, notFoundComponent, pendingComponent and the default*Component router options take .vue files or h()-style function components (src/route.ts:54-58, src/router.ts:26-65).

Setup with Vite (file-based routing)

npm install @tanstack/vue-router
npm install -D @tanstack/router-plugin @vitejs/plugin-vue @vitejs/plugin-vue-jsx
// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { tanstackRouter } from '@tanstack/router-plugin/vite'

export default defineConfig({
  plugins: [
    tanstackRouter({ target: 'vue', autoCodeSplitting: true }), // before vue()
    vue(),
    vueJsx(), // needed for .tsx route files
  ],
})

Source: official Vue example, https://github.com/TanStack/router/blob/main/examples/vue/basic-file-based-sfc/vite.config.ts

// src/main.ts
import { createApp, h } from 'vue'
import { RouterProvider, createRouter } from '@tanstack/vue-router'
import { routeTree } from './routeTree.gen'

const router = createRouter({
  routeTree,
  defaultPreload: 'intent',
  scrollRestoration: true,
})

declare module '@tanstack/vue-router' {
  interface Register {
    router: typeof router
  }
}

createApp({ setup: () => () => h(RouterProvider, { router }) }).mount('#app')

File naming, split-file conventions (.route.ts, .component.vue, .lazy.ts), and the generated routeTree.gen.ts: references/file-based-routing.md.

Code-based routing

import { h } from 'vue'
import { createRootRouteWithContext, createRoute, createRouter, Outlet } from '@tanstack/vue-router'

interface RouterContext { auth: { isAuthenticated: boolean } }

const rootRoute = createRootRouteWithContext<RouterContext>()({ component: () => h(Outlet) })

const postsRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: 'posts',
  loader: ({ context }) => fetchPosts(context.auth),
})

const routeTree = rootRoute.addChildren([postsRoute])
const router = createRouter({
  routeTree,
  context: { auth: { isAuthenticated: false } },
})

Route options, hooks on route objects, and property-order rules: references/routes.md.

Composables

ComposableReturnsNotes
useRouter()router instancenot a ref
useRouterState({ select })Ref<T>pass select to avoid re-renders
useNavigate({ from? })functionnot a ref
useSearch({ from })Ref<T>throws unless from matches
useParams({ from })Ref<T>
useMatch({ from })Ref<T>
useLoaderData({ from })Ref<T>
useLoaderDeps({ from })Ref<T>
useRouteContext({ from })Ref<T>
useLocation()Ref<ParsedLocation>
useMatches() / useParentMatches() / useChildMatches()Ref<Array<Match>>accepts select
useMatchRoute()functioncalling it returns Ref<false | params> (src/Matches.tsx:148-172)
useLinkProps(options)link props objectfor custom anchors
useBlocker({ shouldBlockFn })void or Ref<BlockerResolver>resolver only with withResolver: true
useCanGoBack()Ref<boolean>location.state.__TSR_index !== 0 (src/useCanGoBack.ts:4-10)
useAwaited({ promise })[data, promise] tuplefor deferred data

Route objects and getRouteApi('/path') expose the same hooks pre-scoped: Route.useSearch(), Route.useLoaderData(), Route.useNavigate(), Route.Link (src/route.ts:72-80).

Details and select/strict semantics: references/composables.md.

Components

ComponentPurpose
<RouterProvider :router="router" />mounts the router; extra attrs update router options (src/RouterProvider.tsx:60-95)
<Link to="..." :params="..." :search="...">type-safe anchor; active state sets data-status="active" + aria-current="page" (src/link.tsx:522-525); default slot receives { isActive } (src/link.tsx:918)
<Outlet />renders matched child route (src/Match.tsx:275)
<Navigate to="..." />declarative redirect, fires in onMounted (src/useNavigate.tsx:24-40)
<MatchRoute to="..." :fuzzy="true">renders slot when matched; scoped slot receives params
<Await :promise="p">deferred data with <Suspense> (src/awaited.tsx:26-43)
<Block :should-block-fn="fn">navigation blocking; scoped slot receives resolver (src/useBlocker.tsx:470-491)
<CatchBoundary> / <ErrorComponent>error boundary via onErrorCaptured
<ClientOnly>renders children only after mount
<HeadContent>, <Scripts>, <Html>, <Body>, <Asset>, <ScriptOnce>SSR document shell

Link options, activeProps (defaults to { class: 'active' }, src/link.tsx:477), preloading (intent/viewport/render), linkOptions(), and createLink(): references/navigation-links.md.

Data loading and redirects

const route = createFileRoute('/posts/$postId')({
  beforeLoad: async ({ context, params }) => {
    if (!context.auth.isAuthenticated) {
      throw redirect({ to: '/login', search: { from: params.postId } })
    }
  },
  loaderDeps: ({ search: { page } }) => ({ page }),
  loader: ({ deps, params }) => fetchPost(params.postId, deps.page),
  pendingComponent: PendingSpinner, // .vue file works too
})

throw redirect(), isRedirect(), deferred streaming with defer(), and context typing: references/data-loading.md.

Search params

import { z } from 'zod' // or plain validators
const route = createFileRoute('/posts')({
  validateSearch: z.object({ page: z.number().default(1) }),
  search: {
    middlewares: [stripSearchParams({ page: 1 })],
  },
})

Validators, input/output schemas, retainSearchParams/stripSearchParams, and custom serialization: references/search-params.md.

Deprecations in 1.170.x (use instead)

DeprecatedReplacementProof
Route, RootRoute, FileRoute, RouteApi classescreateRoute, createRootRoute, createFileRoute, getRouteApisrc/route.ts:95, src/route.ts:220, src/route.ts:460, src/fileRoute.ts:57
rootRouteWithContextcreateRootRouteWithContextsrc/route.ts:414
NotFoundRoute / routerOptions.notFoundRoutenotFoundComponent route option / defaultNotFoundComponent router optionhttps://tanstack.com/router/latest/docs/framework/vue/guide/not-found-errors
<ScrollRestoration />scrollRestoration: true in createRoutersrc/ScrollRestoration.tsx:18
opts.navigate in beforeLoad/loaderthrow redirect({ to })https://tanstack.com/router/latest/docs/framework/vue/api/router/RouteOptionsType
parseParams/stringifyParamsparams.parse/params.stringifysame RouteOptionsType doc
preSearchFilters/postSearchFilterssearch.middlewaressame RouteOptionsType doc
FileRouteLoader / separate .lazy.ts loader fileskeep the loader in the route filesrc/fileRoute.ts:153
useBlocker(fn, condition) legacy signatures{ shouldBlockFn } objectsrc/useBlocker.tsx:139-151

Best practices

References

  • references/api-surface.md — every public export, grouped
  • references/composables.md — hook signatures and Ref semantics
  • references/routes.md — route creation, options, route hooks
  • references/navigation-links.md — Link, navigation, blocking, preloading
  • references/data-loading.md — loaders, context, redirects, deferred data
  • references/search-params.md — validation and middlewares
  • references/file-based-routing.md — Vite plugin, naming, code splitting
  • references/ssr.md — server entry points and document shell components

FAQ

What does the tanstack-vue-router-skilld skill do?

Use when writing, debugging, or refactoring code that imports @tanstack/vue-router (TanStack Router for Vue). Covers setup, file-based and code-based routes, composables returning Ref, Link, loaders, search params, SSR, and v1.170.x deprecations.

How do I install tanstack-vue-router-skilld?

Run npx skills add https://github.com/skilld-dev/vue-ecosystem-skills --skill tanstack-vue-router-skilld in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/tanstack-vue-router-skilld/ (personal) or .claude/skills/tanstack-vue-router-skilld/ (project).

Which AI agents can use tanstack-vue-router-skilld?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is tanstack-vue-router-skilld safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains tanstack-vue-router-skilld?

It is published by skilld-dev in skilld-dev/vue-ecosystem-skills. It has 100 recorded installs.

More from skilld-dev/vue-ecosystem-skills

View all →

quasar-skilld

skilld-dev/vue-ecosystem-skills

Build, configure, and debug apps with the Quasar framework (quasar npm package, v2.33.1). Use when writing, reviewing, or debugging code that imports "quasar" or "quasar/wrappers", configuring Quasar with Vite, Vitest, Storybook, UMD, or Quasar CLI, styling with Quasar Sass variables, or upgrading between Quasar v2 releases.

Frontend & Design661 installs

vue-i18n-skilld

skilld-dev/vue-ecosystem-skills

Open the skill to read its SKILL.md instructions.

Frontend & Design401 installs

vue-skilld

skilld-dev/vue-ecosystem-skills

Open the skill to read its SKILL.md instructions.

Frontend & Design397 installs

vuetify-skilld

skilld-dev/vue-ecosystem-skills

Vue Material Component Framework. Use when writing, debugging, or configuring code that imports vuetify v4.x. Covers createVuetify setup, components and labs, composables, theming, icons, dates and locale, styles and SASS variables, treeshaking, and v3 to v4 migration.

Frontend & Design380 installs

pinia-skilld

skilld-dev/vue-ecosystem-skills

Open the skill to read its SKILL.md instructions.

Frontend & Design313 installs

vue-router-skilld

skilld-dev/vue-ecosystem-skills

Open the skill to read its SKILL.md instructions.

Frontend & Design285 installs

Popular frontend & design skills

View category →

setup-matt-pocock-skills

mattpocock/skills

Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.

Frontend & Design1.1M installs

frontend-design

anthropics/skills

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

OfficialFrontend & Design1M installs

hyperframes-animation

heygen-com/hyperframes

All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.

prototype

mattpocock/skills

Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

Frontend & Design999.2K installs

hyperframes-core

heygen-com/hyperframes

The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.

Frontend & Design930.5K installs

vercel-react-best-practices

vercel-labs/agent-skills

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

OfficialFrontend & Design843.1K installs