TanStack Start full-stack React framework. Use for: server functions with createServerFn, TanStack Router file-based routing, TanStack Query SSR integration, Cloudflare Workers deployment.
Build and deploy full-stack React apps with TanStack Start. Use when creating server functions, file-based routing, or deploying to Cloudflare Workers.
/plugin marketplace add ferdousbhai/tanstack-start/plugin install ferdousbhai-tanstack-start@ferdousbhai/tanstack-startThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/better-auth.mdreferences/cloudflare-deployment.mdreferences/github-actions-deploy.mdreferences/migration.mdreferences/query-integration.mdreferences/routing.mdreferences/server-functions.mdreferences/server-routes.mdFull-stack React framework with SSR, server functions, and Vite bundling.
New project:
pnpm create cloudflare@latest my-app --framework=tanstack-start -y --no-deploy
Existing app: See references/migration.md for converting React/Vite apps.
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
tsConfigPaths(),
tanstackStart(),
viteReact(), // MUST come AFTER tanstackStart
],
})
Do NOT enable verbatimModuleSyntax - it leaks server bundles into client bundles.
See references/server-functions.md for complete guide.
⚠️ Critical: Route loaders run on server for initial SSR, but run on CLIENT during navigation. Always wrap server code in
createServerFn()to ensure it runs server-side.
When to use what (Cloudflare Workers):
| Use Case | Solution |
|---|---|
| Server code in route loaders | createServerFn() |
| Server code from client event handlers | API routes (server.handlers) work best |
| Access Cloudflare bindings | import { env } from 'cloudflare:workers' |
createServerFn - for loaders:
import { createServerFn } from '@tanstack/react-start'
export const getData = createServerFn().handler(async () => {
return { data: process.env.SECRET } // Server-only
})
API routes - for client event handlers:
// routes/api/users.ts
export const Route = createFileRoute('/api/users')({
server: {
handlers: {
POST: async ({ request }) => {
const body = await request.json()
return Response.json(await db.users.create(body))
},
},
},
})
// In component: fetch('/api/users', { method: 'POST', body: JSON.stringify(data) })
Key APIs:
createServerFn() - Server-only functions for loadersserver.handlers - API routes for client event handlerscreateMiddleware({ type: 'function' }) - Reusable middleware@tanstack/react-start/server: getRequestHeaders(), setResponseHeader(), getCookies()See references/routing.md for complete patterns.
File conventions in src/routes/:
| Pattern | Route |
|---|---|
index.tsx | / |
posts.$postId.tsx | /posts/:postId |
_layout.tsx | Layout (no URL) |
__root.tsx | Root layout (required) |
import { createFileRoute } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start'
const getPost = createServerFn()
.handler(async () => await db.post.findFirst())
export const Route = createFileRoute('/posts/$postId')({
loader: ({ params }) => getPost({ data: params.postId }),
component: () => {
const post = Route.useLoaderData()
return <h1>{post.title}</h1>
},
})
See references/cloudflare-deployment.md for complete guide.
pnpm add -D @cloudflare/vite-plugin wrangler
vite.config.ts - add cloudflare plugin:
import { cloudflare } from '@cloudflare/vite-plugin'
// Add to plugins: cloudflare({ viteEnvironment: { name: 'ssr' } })
wrangler.jsonc:
{
"$schema": "./node_modules/wrangler/config-schema.json",
"name": "my-app",
"compatibility_date": "<CURRENT_DATE>", // Use today's YYYY-MM-DD
"compatibility_flags": ["nodejs_compat"],
"main": "@tanstack/react-start/server-entry",
"observability": { "enabled": true }
}
Access Cloudflare bindings in server functions:
import { env } from 'cloudflare:workers'
const value = await env.MY_KV.get('key')
Static Prerendering (v1.138.0+):
tanstackStart({ prerender: { enabled: true } })
See references/query-integration.md for SSR setup.
pnpm add @tanstack/react-query @tanstack/react-router-ssr-query
// Preload in loaders, consume with useSuspenseQuery
loader: ({ context }) => context.queryClient.ensureQueryData(myQueryOptions)
See references/better-auth.md for complete guide.
⚠️ Critical: Use
createFileRoutewithserver.handlers, NOT the legacycreateAPIFileRoute.
Mount the auth handler at /src/routes/api/auth/$.ts:
import { auth } from '@/lib/auth'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/api/auth/$')({
server: {
handlers: {
GET: ({ request }) => auth.handler(request),
POST: ({ request }) => auth.handler(request),
},
},
})
Auth config with tanstackStartCookies plugin:
import { betterAuth } from "better-auth"
import { tanstackStartCookies } from "better-auth/tanstack-start"
export const auth = betterAuth({
// ...your config
plugins: [tanstackStartCookies()] // MUST be last plugin
})
Protect routes with middleware:
import { createMiddleware } from "@tanstack/react-start"
import { getRequestHeaders } from "@tanstack/react-start/server"
import { auth } from "./auth"
export const authMiddleware = createMiddleware().server(
async ({ next }) => {
const session = await auth.api.getSession({ headers: getRequestHeaders() })
if (!session) throw redirect({ to: "/login" })
return next()
}
)
// In route:
export const Route = createFileRoute('/dashboard')({
server: { middleware: [authMiddleware] },
component: Dashboard,
})
See references/github-actions-deploy.md for CI/CD setup with preview deployments.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.