Overview
ZeroStarter can be deployed to Vercel for both the frontend (Next.js) and backend (Hono) applications. This guide covers the deployment configuration for both parts of the monorepo.Frontend and backend must be deployed as two separate Vercel projects. Each project has its own configuration, environment variables, and deployment lifecycle.
Prerequisites
Before deploying to Vercel, ensure you have:- A Vercel account
- Your repository pushed to GitHub, GitLab, or Bitbucket
- A PostgreSQL database (e.g., Neon, Supabase, or Railway)
- OAuth credentials (GitHub and/or Google)
Deployment Configuration
Backend Project (Hono API)
ZeroStarter includes avercel.json configuration for the Hono backend:
api/hono/vercel.json
The build commands navigate to the repository root (
../..) to leverage Turbo’s monorepo build system.Frontend Project (Next.js)
The Next.js frontend also includes avercel.json configuration:
web/next/vercel.json
Deployment Steps
Deploy Backend First
- Go to your Vercel dashboard and click “Add New Project”
- Select your ZeroStarter repository
- Set Root Directory to
api/hono - Vercel will auto-detect the configuration from
vercel.json - Add backend environment variables (see below)
- Click “Deploy”
- Important: Copy the deployment URL (e.g.,
https://your-api.vercel.app) - you’ll need it for the frontend
Deploy Frontend
- Go to Vercel dashboard and click “Add New Project”
- Select the same ZeroStarter repository
- Set Root Directory to
web/next - Add frontend environment variables (see below)
- Use the backend URL from Step 1 for
NEXT_PUBLIC_API_URL - Click “Deploy”
Environment Variables
Backend Environment Variables
Add these in your backend Vercel project settings:Frontend Environment Variables
Add these in your frontend Vercel project settings:Build Configuration Reference
Backend (Hono)
| Option | Value |
|---|---|
| Root Directory | api/hono |
| Framework | Hono |
| Install Command | cd ../.. && bun install --ignore-scripts |
| Build Command | cd ../.. && turbo build --filter=@api/hono |
| Output Directory | dist |
| Bun Version | 1.3.7 |
Frontend (Next.js)
| Option | Value |
|---|---|
| Root Directory | web/next |
| Framework | Next.js |
| Install Command | cd ../.. && bun install --ignore-scripts |
| Build Command | cd ../.. && turbo build --filter=@web/next |
| Output Directory | .next (auto-detected) |
| Bun Version | 1.3.7 |
Custom Domains
After successful deployment, configure custom domains:Add Domain in Vercel
- Go to your project settings in Vercel
- Navigate to “Domains”
- Add your custom domain (e.g.,
api.yourdomain.comfor backend,yourdomain.comfor frontend)
Update Environment Variables
Update the following environment variables with your custom domains:Backend:
HONO_APP_URLHONO_TRUSTED_ORIGINS
NEXT_PUBLIC_APP_URLNEXT_PUBLIC_API_URL
Database Recommendations
For production, use a managed PostgreSQL service with connection pooling:- Neon - Serverless Postgres with automatic scaling
- Supabase - Postgres with real-time features and authentication
- Railway - Simple managed Postgres databases
ZeroStarter requires PostgreSQL. MySQL-compatible providers like PlanetScale are not supported without substantial schema and driver changes.
Monorepo Considerations
Turborepo Build Filtering
The build commands use Turbo’s--filter flag to build only the necessary packages:
Shared Packages
Both projects share these workspace packages:@packages/auth- Better Auth configuration@packages/env- Environment variable validation with Zod@packages/db- Drizzle ORM schema and database utilities
Troubleshooting
Build Fails with “Module not found”
Ensure your build command includescd ../.. to access the monorepo root:
Environment Variables Not Loading
- Check that variables are added to the correct project (backend vs frontend)
- Verify variable names match exactly (including
NEXT_PUBLIC_prefix for frontend) - Redeploy after adding new environment variables
CORS Errors
EnsureHONO_TRUSTED_ORIGINS in the backend includes your frontend URL:
OAuth Redirect Mismatch
Verify OAuth callback URLs match your production API URL:Production Checklist
Security
- Generate a strong
BETTER_AUTH_SECRET(32+ characters) - Configure
HONO_TRUSTED_ORIGINSto only include your frontend domain - Set up rate limiting with
HONO_RATE_LIMIT
Database
- Use a production-grade PostgreSQL database
- Enable connection pooling
- Run migrations:
bun run db:migrate
OAuth
- Update callback URLs in GitHub/Google developer consoles
- Test login flow with production URLs