Full Stack Template
The full-stack template provides everything you need to build a complete web application with authentication, database, and a modern React frontend.
Features
- ✅ React Frontend with Vite and TanStack Router
- ✅ Hono API with type-safe RPC
- ✅ Cloudflare D1 database with Drizzle ORM
- ✅ Better Auth with Discord OAuth
- ✅ Type-safe API client auto-generated with Orval
- ✅ Tailwind CSS for styling
- ✅ Vitest for testing
Quick Start
Or skip the prompts:
Project Structure
Key Files
Development Workflow
1. Start Development Server
This starts:
- Vite dev server on port 5173
- Wrangler on port 8787
- File watchers for type generation
2. Create a New Module
This generates:
- Database table schema
- API routes and handlers
- TypeScript types
- Test files
- Frontend hooks
3. Run Tests
4. Build for Production
Authentication Setup
- Create a Discord application at https://discord.com/developers
- Add OAuth redirect:
http://localhost:8787/api/auth/callback/discord
- Update
.dev.vars
:
Database Migrations
Type Generation
Types are automatically generated for:
- Routes - TanStack Router types
- API Client - Orval generates typed fetch functions
- Database - Drizzle generates table types
- Environment - Wrangler generates CloudflareBindings
Run manually with:
Deployment
Deploy to Cloudflare Workers:
Set production secrets:
Best Practices
- Module Organization - Keep related code together in modules
- Type Safety - Let TypeScript guide your development
- Testing - Write tests for critical paths
- Environment Variables - Never commit secrets
- Database Migrations - Always use migrations for schema changes
Common Tasks
Add a New Page
Create a new file in src/client/routes/
:
Add an API Endpoint
Create a new route in src/server/modules/
:
Query the Database
Troubleshooting
- Types not updating? Run
npm run gen:types
- Database errors? Check migrations with
npm run db:push:local
- Auth not working? Verify Discord credentials in
.dev.vars
- Build failing? Ensure all dependencies are installed
Next Steps
- Learn about authentication
- Explore database setup
- Read about deployment