The best way to build a full-stack SaaS application π
Documentation β’ Quick Start β’ Contributing
npx create-craft-app@latest my-app
cd my-app
cp .env.example .env
pnpm devThis monorepo includes the following:
apps/www- Documentation site built with Nextra
packages/create-craft-app- CLI tool for scaffolding new projects
tooling/typescript- Shared TypeScript configurationstooling/eslint- Shared ESLint configurationstooling/prettier- Shared Prettier configuration
- π€ Multi-Provider AI - OpenAI, Anthropic, and Google AI models with Vercel AI SDK 6
- π Authentication - Email/password + OAuth (Google, GitHub) with Better Auth
- πΎ Database - PostgreSQL with Neon serverless + Drizzle ORM
- π³ Payments - Subscription billing with Dodo Payments
- π§ Transactional Emails - React Email templates with Resend
- π Background Jobs - Trigger.dev for async tasks
- π Analytics - PostHog for product analytics
- π¬ Customer Support - Tawk.to live chat integration
- π¨ UI Components - shadcn/ui + Tailwind CSS v4
- π Dark Mode - System-aware theme switching
- β‘ Caching - Upstash Redis for rate limiting & caching
- π File Storage - Cloudflare R2 (S3-compatible)
- π‘οΈ Type Safety - End-to-end TypeScript with strict mode
- β Code Quality - ESLint, Prettier, Husky pre-commit hooks
| Category | Technology |
|---|---|
| Framework | Next.js 16 with App Router & Turbopack |
| Language | TypeScript 5.9 |
| Styling | Tailwind CSS v4 + shadcn/ui |
| Database | Neon PostgreSQL + Drizzle ORM |
| Authentication | Better Auth |
| AI | Vercel AI SDK 6 (OpenAI, Anthropic, Google) |
| Payments | Dodo Payments |
| Resend + React Email | |
| Cache | Upstash Redis |
| Storage | Cloudflare R2 |
| Background Jobs | Trigger.dev |
| Analytics | PostHog |
| Support | Tawk.to |
| Deployment | Vercel |
src/
βββ app/ # Next.js App Router
β βββ (auth)/ # Auth pages (login, register)
β βββ (dashboard)/ # Protected dashboard pages
β βββ api/ # API routes
β β βββ auth/ # Better Auth handler
β β βββ chat/ # AI chat endpoint
β β βββ webhooks/ # Payment webhooks
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Landing page
βββ components/
β βββ layout/ # Dashboard layout components
β βββ providers/ # Context providers
β βββ settings/ # Settings components
β βββ ui/ # shadcn/ui components
βββ lib/
β βββ ai/ # AI models, prompts, tools
β βββ auth/ # Better Auth configuration
β βββ cache/ # Redis client & rate limiters
β βββ db/ # Drizzle schema & client
β βββ email/ # Resend client & templates
β βββ payments/ # Dodo Payments integration
β βββ storage/ # R2 storage utilities
β βββ analytics/ # PostHog client
βββ trigger/ # Trigger.dev background tasks
βββ env.ts # Environment validation (T3 Env)
βββ proxy.ts # Next.js proxy (auth protection)
- Node.js 20+
- pnpm 9+
- PostgreSQL database (recommend Neon)
- Clone the repository
git clone https://github.com/yourusername/craftjs.git
cd craftjs- Install dependencies
pnpm install- Set up environment variables
cp .env.example .envFill in your environment variables (see Environment Variables section).
- Set up the database
pnpm db:push- Run the development server
pnpm devOpen http://localhost:3000 to see your app.
Create a .env file based on .env.example:
# Database (Neon PostgreSQL)
DATABASE_URL="postgresql://..."
# Authentication (Better Auth)
BETTER_AUTH_SECRET="your-secret-key"
BETTER_AUTH_URL="http://localhost:3000"
# OAuth Providers (optional)
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET=""
# AI Providers (at least one required)
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""
GOOGLE_GENERATIVE_AI_API_KEY=""
# Payments (Dodo Payments)
DODO_API_KEY=""
DODO_WEBHOOK_SECRET=""
# Email (Resend)
RESEND_API_KEY=""
RESEND_FROM_EMAIL="noreply@yourdomain.com"
# Cache (Upstash Redis)
UPSTASH_REDIS_REST_URL=""
UPSTASH_REDIS_REST_TOKEN=""
# Storage (Cloudflare R2)
R2_ACCOUNT_ID=""
R2_ACCESS_KEY_ID=""
R2_SECRET_ACCESS_KEY=""
R2_BUCKET_NAME=""
R2_PUBLIC_URL=""
# Analytics (PostHog)
NEXT_PUBLIC_POSTHOG_KEY=""
NEXT_PUBLIC_POSTHOG_HOST="https://us.i.posthog.com"
# Customer Support (Tawk.to)
NEXT_PUBLIC_TAWK_PROPERTY_ID=""
NEXT_PUBLIC_TAWK_WIDGET_ID=""
# Background Jobs (Trigger.dev)
TRIGGER_SECRET_KEY=""| Script | Description |
|---|---|
pnpm dev |
Start development server with Turbopack |
pnpm build |
Build for production |
pnpm start |
Start production server |
pnpm lint |
Run ESLint |
pnpm format |
Format code with Prettier |
pnpm format:check |
Check formatting |
pnpm db:push |
Push schema changes to database |
pnpm db:studio |
Open Drizzle Studio |
pnpm db:generate |
Generate migrations |
pnpm db:migrate |
Run migrations |
Better Auth provides:
- Email/Password - Built-in with email verification
- OAuth - Google and GitHub providers configured
- Session Management - Secure cookie-based sessions
- Protected Routes - Proxy-based route protection
The boilerplate supports multiple AI providers:
// Available models
const models = {
"gpt-4o": openai("gpt-4o"),
"gpt-4o-mini": openai("gpt-4o-mini"),
"claude-sonnet-4": anthropic("claude-sonnet-4-20250514"),
"claude-3-5-haiku": anthropic("claude-3-5-haiku-latest"),
"gemini-2-flash": google("gemini-2.0-flash"),
};Features:
- Streaming responses
- Tool calling support
- Rate limiting per user
- Usage tracking
Pre-configured plans with Dodo Payments:
| Plan | Price | Features |
|---|---|---|
| Free | $0/mo | 100 AI requests, 10MB storage |
| Pro | $19/mo | 10,000 AI requests, 10GB storage |
| Enterprise | $99/mo | Unlimited requests, 100GB storage |
- Push your code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy!
The app can be deployed to any platform supporting Next.js:
- AWS (Amplify, Lambda)
- Google Cloud Run
- Railway
- Render
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Built with these amazing open source projects:
Made with β€οΈ for the AI developer community