/mindrally-skills:tanstack-routerfrom Mindrally Skills Collection
Type-safe, file-based routing for React with TanStack Router. Covers createFileRoute, Zod search param validation, route loaders, beforeLoad auth guards, TanStack Query integration, and router context/preloading.
Ships in Mindrally Skills Collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
TanStack Router is a fully type-safe router for React that treats routes, loaders, params, and search params as first-class typed data rather than untyped strings.
src/routes/ following the file-based routing convention (see below).Route from createFileRoute('/path')({...}) with component, and optionally loader, validateSearch, beforeLoad, errorComponent, and pendingComponent.validateSearch.loader, not in a component useEffect; integrate with TanStack Query via queryClient.ensureQueryData when caching is needed.beforeLoad checks (e.g. auth) that throw redirect({ to: '/login' }) when a precondition fails.<Link to="/path" params={...} search={...}> so the compiler validates params and search at every call site.routeTree.gen.ts is regenerated (automatic under the Vite plugin's dev server / build) before running or building the app.@tanstack/router-vite-plugin (or @tanstack/router-plugin/vite) for scalability over manually constructed route trees.createFileRoute (leaf/nested routes) or createRootRoute / createRootRouteWithContext (root).loader functions, not in component useEffect — this enables preloading, parallel loading, and pending/error states.src/routes/
__root.tsx ← Root layout
index.tsx ← / route
posts/
index.tsx ← /posts
$postId.tsx ← /posts/:postId (dynamic segment)
_layout.tsx ← Layout route (no path segment)
_auth/ ← Pathless auth layout group
dashboard.tsx
_layout, _auth) creates a pathless layout route used purely for grouping/shared UI.$ prefix ($postId) marks a dynamic path segment, matching Route.useParams().index.tsx inside a folder matches the folder's own path with no additional segment.export const Route = createFileRoute('/posts/$postId')({
loader: async ({ params }) => fetchPost(params.postId),
component: PostComponent,
errorComponent: ({ error }) => <ErrorBanner message={error.message} />,
pendingComponent: () => <PostSkeleton />,
})
function PostComponent() {
const post = Route.useLoaderData() // type-safe
const { postId } = Route.useParams() // type-safe
return <div>{post.title}</div>
}
errorComponent renders when the loader throws; pendingComponent renders while the loader is in flight (subject to defaultPendingMs).useLoaderData() and errorComponent respectively.validateSearch.Route.useSearch() — never read window.location.search or URLSearchParams directly, which bypasses type safety and validation.const searchSchema = z.object({
page: z.number().int().min(1).default(1),
q: z.string().optional(),
})
export const Route = createFileRoute('/search')({
validateSearch: searchSchema,
component: SearchPage,
})
function SearchPage() {
const { page, q } = Route.useSearch()
const navigate = Route.useNavigate()
return (
<button onClick={() => navigate({ search: (prev) => ({ ...prev, page: page + 1 }) })}>
Next page
</button>
)
}
<Link> for internal navigation — never a raw <a href>, which triggers a full page reload and loses client-side routing state.params and search; the TypeScript compiler catches missing or mistyped route params at build time.<Link to="/posts/$postId" params={{ postId: '123' }}>View Post</Link>
<Link to="/search" search={{ page: 1, q: 'react' }}>Search</Link>
QueryClient in router context so loaders can prefetch and cache through TanStack Query rather than duplicating fetch logic.ensureQueryData (not fetchQuery) in loaders so an already-cached query is reused instead of refetched.export const Route = createFileRoute('/posts')({
loader: ({ context: { queryClient } }) =>
queryClient.ensureQueryData(postsQueryOptions()),
component: PostsPage,
})
function PostsPage() {
const { data: posts } = useSuspenseQuery(postsQueryOptions())
return <PostList posts={posts} />
}
// __root.tsx
interface RouterContext {
queryClient: QueryClient
auth: AuthState
}
export const Route = createRootRouteWithContext<RouterContext>()({
component: RootLayout,
})
// main.tsx
const router = createRouter({ routeTree, context: { queryClient, auth } })
loader and beforeLoad via the context argument, giving each route typed access to shared dependencies without prop drilling or global singletons.export const Route = createFileRoute('/_auth/dashboard')({
beforeLoad: ({ context }) => {
if (!context.auth.isAuthenticated) throw redirect({ to: '/login' })
},
component: Dashboard,
})
beforeLoad runs before the loader and before the component renders, making it the right place for auth checks, feature flag gates, and redirects.throw redirect(...) over imperative navigation inside components — it works during SSR, preloading, and client navigation alike.defaultPreload: 'intent' on the router so links prefetch their route's data on hover/focus, making navigation feel instant.React.lazy (or the router's built-in code-splitting via .lazy() route files) for route component code splitting on large apps.@tanstack/router-devtools and render <TanStackRouterDevtools /> in development to inspect route matches, pending states, and cache.useEffect inside a route component instead of a loader, which loses preloading and creates render-then-fetch waterfalls.window.location.search instead of Route.useSearch(), bypassing the search param schema and type safety.useEffect redirect) instead of beforeLoad, allowing a flash of protected content before redirecting.<Link> call sites — let the compiler catch it rather than testing manually.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
265 skills in this plugin
/accessibility-a11yImplement web accessibility (a11y) best practices following WCAG guidelines to create inclusive, accessible user interfaces./alpine-jsAlpine.js development guidelines for lightweight reactive interactions with Tailwind CSS and various backend frameworks./analytics-data-analysisBest practices for analytics, data analysis, and visualization using Python, pandas, matplotlib, seaborn, and Jupyter notebooks. Use when performing exploratory data analysis, building data pipelines, creating statistical visualizations, writing Jupyter notebooks, cleaning and transforming datasets, or implementing analytics dashboards./android-developmentAndroid development guidelines for Kotlin with clean architecture, MVI pattern, Material Design, and best practices for building robust mobile applications/angularExpert in Angular TypeScript development with scalable, high-performance patterns/angular-developmentExpert guidance for Angular and TypeScript development focused on scalable, high-performance web applicationsnpx claudepluginhub mindrally/skills --plugin mindrally-skillsOther plugins' skills for the same job