All skills
skilld-dev avatar

/tanstack-vue-router-skilld

@b9c39cb

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.

Use this Skill: https://skilld.dev/gh/skilld-dev/vue-ecosystem-skills/tanstack-vue-router-skilld

This session only. Nothing lands on disk.

referencesroutes.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Routes and route options

Creation

  • Code-based: createRoute({ getParentRoute: () => parentRoute, path, ...options }), then compose with rootRoute.addChildren([...]). path is relative to the parent; use path: '/posts' only at the top level.
  • Root: createRootRoute(options); with injected context: createRootRouteWithContext<TRouterContext>()(options) — the context type is then enforced by createRouter({ context }) (src/route.ts:376-411).
  • File-based: createFileRoute('/posts/$postId')(options) — the path argument is validated against the generated FileRoutesByPath (src/fileRoute.ts:38-54).
  • Lazy: createLazyRoute(id) / createLazyFileRoute(path) return route option subsets loaded on demand.

Components in options accept .vue SFC imports, defineComponent results, or (props) => VNode functions (src/route.ts:54-66).

Frequently used options

Option Purpose
component, pendingComponent, errorComponent, notFoundComponent render pipeline; router-level fallbacks via defaultComponent, defaultPendingComponent, defaultErrorComponent, defaultNotFoundComponent (src/router.ts:18-75)
validateSearch schema or (search) => search producing typed search (references/search-params.md)
params.parse / params.stringify custom path param codecs (replace deprecated parseParams/stringifyParams)
loaderDeps, loader data loading (references/data-loading.md)
beforeLoad guard; may throw redirect() / notFound(); returns route context
head, headers, scripts server-side document management (meta/link/style tags, HTTP headers, script tags) — https://tanstack.com/router/latest/docs/framework/vue/guide/document-head-management
search.middlewares composable search transform pipeline; helpers retainSearchParams, stripSearchParams
preloader custom preloading per route
staleTime, preloadStaleTime, gcTime caching windows
remountDeps `(opts) => boolean
context (partial), select, shouldThrow consumed by route hooks
ssr: false or 'data-only' skip or data-only SSR for the route (src/Match.tsx:67)
codeSplitGroupings chunk grouping for split assets: Array<Array<'loader'|'component'|'pendingComponent'|'notFoundComponent'|'errorComponent'>>
caseSensitive, enableRouteMasking (with createRouteMask) matching and URL masking

Full option docs: https://tanstack.com/router/latest/docs/framework/vue/api/router/RouteOptionsType

Property order matters for inference

validateSearch and params must precede loaderDeps; beforeLoad must precede loader; otherwise context and deps do not flow through. The @tanstack/eslint-plugin-router rule create-route-property-order is auto-fixable — https://tanstack.com/router/latest/docs/framework/vue/eslint/create-route-property-order

Router options highlights

  • routeTree (required), context, basepath, defaultPreload ('intent' | 'viewport' | 'render' | false), defaultPreloadMaxAge (default 30 000 ms), defaultPreloadDelay
  • defaultStaleTime, defaultGcTime, defaultStructuralSharing (enables structural sharing for select results), defaultRemountDeps
  • scrollRestoration: true, scrollToTopSelectors
  • notFoundMode, defaultNotFoundComponent, disableGlobalCatchBoundary (removes the root CatchBoundary, src/Matches.tsx:104)
  • trailingSlash, stringifySearch/parseSearch, search.strict
  • defaultViewTransition: boolean | ViewTransitionOptions (View Transitions API)
  • protocolAllowlist + exported DEFAULT_PROTOCOL_ALLOWLIST (XSS guard for absolute URLs)
  • rewrite: { input?, output? } and composeRewrites(...) for bidirectional URL transformation
  • Wrap / InnerWrap components wrap the whole tree or inner content (src/router.ts:57-65)
  • history: createBrowserHistory() | createHashHistory() | createMemoryHistory()

Full list: https://tanstack.com/router/latest/docs/framework/vue/api/router/RouterOptionsType

Router instance methods

router.navigate(options), router.buildLocation(options), router.invalidate(), router.matchRoute(...), router.preloadRoute(...), router.subscribe('onBeforeNavigate', listener), router.dispose(). Events: onBeforeLoad, onLoad, onBeforeNavigate, onNavigation, onResolved, onRendered — https://tanstack.com/router/latest/docs/framework/vue/api/router/RouterEventsType

Source: SKILL.md on GitHub

1 warning9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The skill is a comprehensive collection of documentation, API references, and guides for the TanStack Router library. It provides technical information and best practices for implementing routing in web applications. No malicious code, prompt injections, or data exfiltration patterns were detected.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: MEDIUM · 1 issue

Signed by skilld at b9c39cb. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated last week

README badge

README badge for skilld-dev/vue-ecosystem-skills/tanstack-vue-router-skilld