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…
от skilld-dev★ 188 звёзд на GitHubОб этом скилле
@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/[email protected],@tanstack/[email protected],@tanstack/vue-store@^0.11.0 - ESM-only (
"type": "module"), nomain/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
- Most composables return
Ref<T>— use.valuein script; templates auto-unwrap.useRouter(),useNavigate(),useLinkProps(),useAwaited()do NOT return refs. Full table in references/composables.md. - Never cast or annotate inferred route/router types. Types come from the route tree and the
Registerdeclaration. - Register the router for type safety — without this,
Link/useNavigate/useSearchaccept any string:
declare module '@tanstack/vue-router' {
interface Register {
router: typeof router
}
}
- Not
vue-router. Never importuseRoute/useRouterfromvue-router, never use<router-view>/<router-link>. beforeLoad/loaderare plain async functions. Vue composables (ref,computed, lifecycle hooks) cannot run inside them. Pass state through routercontext.- Route options accept Vue SFCs:
component,errorComponent,notFoundComponent,pendingComponentand thedefault*Componentrouter options take.vuefiles orh()-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
| Composable | Returns | Notes |
|---|---|---|
useRouter() |
router instance | not a ref |
useRouterState({ select }) |
Ref<T> |
pass select to avoid re-renders |
useNavigate({ from? }) |
function | not 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() |
function | calling it returns Ref<false | params> (src/Matches.tsx:148-172) |
useLinkProps(options) |
link props object | for 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] tuple |
for deferred data |
Route objects and getRouteApi('/path') expose the same hooks pre-scoped: `Route.
Установить tanstack-vue-router-skilld в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл tanstack-vue-router-skilld?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tanstack-vue-router-skilld запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic