一键导入
tanstack-start
Full-stack React framework powered by TanStack Router with SSR, streaming, server functions, and deployment to any hosting provider.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Full-stack React framework powered by TanStack Router with SSR, streaming, server functions, and deployment to any hosting provider.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Codebase intelligence for JavaScript and TypeScript. Free static layer finds unused code (files, exports, types, dependencies), code duplication, circular dependencies, complexity hotspots, architecture boundary violations, and feature flag patterns. Runtime coverage merges production execution data into the same health report for hot-path review, cold-path deletion confidence, and stale-flag evidence: a single local capture is free, while continuous/cloud runtime monitoring is paid. 90 framework plugins, zero configuration, sub-second static analysis. Use when asked to analyze code health, find unused code, detect duplicates, check circular dependencies, audit complexity, check architecture boundaries, detect feature flags, clean up the codebase, auto-fix issues, merge runtime coverage, or run fallow.
Generate PR description and automatically create pull request on GitHub
Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.
Adopt better-result in an existing TypeScript codebase. Use when replacing try/catch, Promise rejection handling, null sentinels, or thrown domain exceptions with typed Result workflows.
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.
| name | tanstack-start |
| description | Full-stack React framework powered by TanStack Router with SSR, streaming, server functions, and deployment to any hosting provider. |
TanStack Start is a full-stack React framework built on TanStack Router, powered by Vite and Nitro (via Vinxi). It provides server-side rendering, streaming, server functions (RPC), middleware, API routes, and deploys to any platform via Nitro presets.
Package: @tanstack/react-start
Router Plugin: @tanstack/router-plugin
Build Tool: Vinxi (Vite + Nitro)
Status: RC (Release Candidate)
RSC Support: React Server Components support is in active development and will land as a non-breaking v1.x addition
npx @tanstack/cli create my-app
# Or manually:
npm install @tanstack/react-start @tanstack/react-router react react-dom
npm install -D @tanstack/router-plugin typescript vite vite-tsconfig-paths
my-app/
app/
routes/
__root.tsx # Root layout
index.tsx # / route
posts.$postId.tsx # /posts/:postId
api/
users.ts # /api/users API route
client.tsx # Client entry
router.tsx # Router creation
ssr.tsx # SSR entry
routeTree.gen.ts # Auto-generated route tree
app.config.ts # TanStack Start config
tsconfig.json
package.json
app.config.ts)import { defineConfig } from "@tanstack/react-start/config";
import viteTsConfigPaths from "vite-tsconfig-paths";
export default defineConfig({
vite: {
plugins: [viteTsConfigPaths({ projects: ["./tsconfig.json"] })],
},
server: {
preset: "node-server", // 'vercel' | 'netlify' | 'cloudflare-pages' | etc.
},
tsr: {
appDirectory: "./app",
routesDirectory: "./app/routes",
generatedRouteTree: "./app/routeTree.gen.ts",
},
});
createServerFn)Server functions provide type-safe RPC calls between client and server.
import { createServerFn } from "@tanstack/react-start";
// GET (data fetching, cacheable)
const getUsers = createServerFn().handler(async () => {
const users = await db.query.users.findMany();
return users;
});
// POST (mutations, side effects)
const createUser = createServerFn({ method: "POST" })
.validator((data: { name: string; email: string }) => data)
.handler(async ({ data }) => {
const user = await db.insert(users).values(data).returning();
return user;
});
import { z } from "zod";
const updateUser = createServerFn({ method: "POST" })
.validator(
z.object({
id: z.string(),
name: z.string().min(1),
email: z.string().email(),
}),
)
.handler(async ({ data }) => {
// data is fully typed: { id: string; name: string; email: string }
return await db.update(users).set(data).where(eq(users.id, data.id));
});
import { createMiddleware } from "@tanstack/react-start";
const loggingMiddleware = createMiddleware().handler(async ({ next }) => {
console.log("Request started");
const result = await next();
console.log("Request completed");
return result;
});
const authMiddleware = createMiddleware().handler(async ({ next }) => {
const request = getWebRequest();
const session = await getSession(request);
if (!session?.user) {
throw redirect({ to: "/login" });
}
// Pass typed context to handler
return next({ context: { user: session.user } });
});
const adminMiddleware = createMiddleware()
.middleware([authMiddleware])
.handler(async ({ next, context }) => {
// context.user is typed from authMiddleware
if (context.user.role !== "admin") {
throw redirect({ to: "/unauthorized" });
}
return next({ context: { isAdmin: true } });
});
// Usage
const adminAction = createServerFn({ method: "POST" })
.middleware([adminMiddleware])
.handler(async ({ context }) => {
// context: { user: User; isAdmin: boolean }
return { success: true };
});
// app/routes/api/users.ts
import { createAPIFileRoute } from "@tanstack/react-start/api";
export const APIRoute = createAPIFileRoute("/api/users")({
GET: async ({ request }) => {
const users = await db.query.users.findMany();
return Response.json(users);
},
POST: async ({ request }) => {
const body = await request.json();
const user = await db.insert(users).values(body).returning();
return new Response(JSON.stringify(user), { status: 201 });
},
});
export const Route = createFileRoute('/dashboard')({
loader: async () => ({
criticalData: await fetchCriticalData(),
deferredData: defer(fetchSlowData()),
}),
component: Dashboard,
})
function Dashboard() {
const { criticalData, deferredData } = Route.useLoaderData()
return (
<div>
<CriticalSection data={criticalData} />
<Suspense fallback={<Loading />}>
<Await promise={deferredData}>
{(data) => <SlowSection data={data} />}
</Await>
</Suspense>
</div>
)
}
// app.config.ts
export default defineConfig({
server: {
preset: "node-server", // Self-hosted Node.js
// preset: 'vercel', // Vercel
// preset: 'netlify', // Netlify
// preset: 'cloudflare-pages', // Cloudflare Pages
// preset: 'aws-lambda', // AWS Lambda
// preset: 'deno-server', // Deno Deploy
// preset: 'bun', // Bun
},
});
createServerFn GET for data fetching (cacheable, preloadable)createServerFn POST for mutations and side effectsbeforeLoad for route-level auth guardsdefer() for non-critical data to improve TTFBdefaultPreload: 'intent' on the router for instant navigationawait in loaders leads to streaming issuesdeclare module '@tanstack/react-router' loses all type safety