Development Workflow
Common Commands
Start Development Server
pnpm run devThis starts the Vite dev server with hot reloading. Your app will be available at the port shown in the terminal (usually http://localhost:3001).
Type Checking
pnpm run types:checkRun this frequently to catch type errors early.
Formatting
# Check formattingpnpm run format:check
# Fix formattingpnpm run format:writeDatabase Operations
-
Create a migration
Change your schema in
src/db/schema.ts, then run:Terminal window pnpm run db:generate -
Run migrations
bash pnpm run db:migrate:localbash pnpm run db:migrate:prod -
View database data
bash pnpm run db:studio:localbash pnpm run db:studio:prod
Cloudflare Types
If you change Cloudflare resources in your wrangler.jsonc (add a KV namespace, change D1 binding name, etc.):
pnpm run cf-typegenThis regenerates the worker-configuration.d.ts file so TypeScript knows about your bindings.
Project Structure
src/├── client/ # Client-only code│ ├── components/ # React components│ ├── hooks/ # Custom hooks│ └── tanstack-db/ # TanStack DB collections├── db/ # Database│ └── schema.ts # Drizzle schema├── embedded-sdk/ # Gateway integration│ ├── client/ # Client SDK│ └── server/ # Server SDK├── routes/ # TanStack Router routes├── server/ # Server-side code│ ├── repositories/ # Data access layer│ └── services/ # Business logic├── serverFunctions/ # TanStack server functions└── app.tsx # App entry pointTips
- Keep client code in
/client- Helps avoid accidentally importing server code on the client - Use server functions for all data mutations - Don’t call repositories directly from components
- Run
types:checkbefore committing - Catches errors that hot reload might miss