tanstack-start
БесплатноБез исполняемых скриптовНе проверенBest practices for TanStack Start, the full-stack React framework built on TanStack Router and Vite/Nitro. Use when building server functions with…
от Mindrally★ 323 звезды на GitHubОб этом скилле
TanStack Start
TanStack Start is a full-stack React framework that layers server functions, SSR, streaming, and API routes on top of TanStack Router and a Vite/Nitro build pipeline, giving end-to-end type safety from server to client.
Workflow for Building a TanStack Start Feature
- Configure the app — Set up
app.config.tswith the Vite plugins and aserver.presetmatching the deployment target. - Define the root route — Create
src/routes/__root.tsxwith the HTML document shell (<html>,<head>,<body>,<Outlet>,<ScrollRestoration>,<Scripts>). - Write server functions — Use
createServerFn()with a.validator()and.handler()for any logic that must run on the server (database access, secrets, file I/O). - Wire server functions into routes — Call server functions from route
loaders for reads and from mutation hooks (useMutation) for writes. - Add API routes for raw HTTP — Use
createAPIFileRoutefor webhooks, OAuth callbacks, or endpoints that external services call directly. - Stream non-critical data — Wrap slow, non-blocking loader data in
defer()and render it with<Suspense>+<Await>. - Deploy — Pick the
server.presetfor the target platform and verify environment variable access rules before shipping.
Core Principles
- TanStack Start = TanStack Router + Vite + Nitro, giving full-stack React with a single type-safe codebase.
createServerFnis the primary mechanism for server-side logic — prefer it over hand-rolled REST endpoints for internal data access.- All TanStack Router conventions apply on top of Start: file-based routing, loaders, search param validation, and router context.
- Streaming and Suspense are first-class citizens; use
defer()for anything that shouldn't block the initial response. - Keep server-only code (secrets, DB clients, filesystem access) strictly inside server functions or API routes — never import it into client components.
Configuration
app.config.ts
import { defineConfig } from '@tanstack/start/config'
import tsConfigPaths from 'vite-tsconfig-paths'
export default defineConfig({
vite: { plugins: [tsConfigPaths()] },
server: {
preset: 'node-server', // or: 'vercel', 'netlify', 'bun', 'cloudflare-pages'
},
})
Root Route HTML Shell
// src/routes/__root.tsx
import { createRootRoute, Outlet, ScrollRestoration } from '@tanstack/react-router'
import { Scripts } from '@tanstack/start'
export const Route = createRootRoute({
component: () => (
<html lang="en">
<head />
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
</body>
</html>
),
})
Server Functions
- Define server functions in a dedicated
src/server/functions/(or colocated*.server.ts) module for discoverability. - Always validate input with
.validator()(Zod is the common choice) before the handler runs — never trust client-supplieddata. - Throw descriptive
Errors (or a typed error) from handlers; TanStack Start serializes thrown errors back to the client. - Server functions can be called directly from loaders, actions, event handlers, or
useMutation— they behave like normal async functions on the client but execute on the server.
// src/server/functions/posts.ts
import { createServerFn } from '@tanstack/start'
import { z } from 'zod'
import { db } from '~/server/db'
export const getPost = createServerFn()
.validator(z.object({ id: z.string() }))
.handler(async ({ data }) => {
const post = await db.post.findUnique({ where: { id: data.id } })
if (!post) throw new Error('Post not found')
return post
})
export const createPost = createServerFn()
.validator(z.object({ title: z.string().min(1), body: z.string() }))
.handler(async ({ data }) => db.post.create({ data }))
Using Server Functions in Routes
export const Route = createFileRoute('/posts/$postId')({
loader: ({ params }) => getPost({ data: { id: params.postId } }),
component: PostDetail,
})
function PostDetail() {
const post = Route.useLoaderData()
return <h1>{post.title}</h1>
}
Mutations with Server Functions
import { useMutation } from '@tanstack/react-query'
import { useQueryClient } from '@tanstack/react-query'
import { createPost } from '~/server/functions/posts'
function NewPostForm() {
const queryClient = useQueryClient()
const mutation = useMutation({
mutationFn: (input: { title: string; body: string }) => createPost({ data: input }),
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['posts'] }),
})
return (
<form
onSubmit={(e) => {
e.preventDefault()
const form = new FormData(e.currentTarget)
mutation.mutate({
title: String(form.get('title')),
body: String(form.get('body')),
})
}}
>
<input name="title" placeholder="Title" required />
<textarea name="body" placeholder="
Установить tanstack-start в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл tanstack-start?
Best practices for TanStack Start, the full-stack React framework built on TanStack Router and Vite/Nitro. Use when building server functions with createServerFn, setting up SSR and streaming with defer()/Await, writing API routes, configuring app.config.ts, or deploying a TanStack Start app to Node, Vercel, Netlify, Bun, or Cloudflare.
Как установить скилл tanstack-start?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tanstack-start запускает скрипты?
Нет, скилл состоит только из инструкций (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