Getting Started with ZeroStarter
A comprehensive guide to setting up and running your ZeroStarter SaaS application
ZeroStarter is a modern, type-safe SaaS starter template that gets you up and running quickly. This guide will walk you through the setup process and help you understand the architecture.
What is ZeroStarter?
ZeroStarter is a production-ready SaaS starter template featuring:
- Monorepo architecture with Turborepo
- Type-safe APIs with Hono RPC
- Modern frontend with Next.js 16
- Secure authentication with Better Auth
- Type-safe database with Drizzle ORM
- Beautiful UI with Shadcn UI components
Prerequisites
Before you begin, ensure you have:
- Bun v1.3.0 or later installed
- A PostgreSQL database (local or hosted)
- A GitHub account (for OAuth setup)
Installation
1. Clone the Template
bunx gitpick https://github.com/nrjdalal/zerostarter/tree/main
cd zerostarter2. Install Dependencies
bun install3. Set Up Environment Variables
Create a .env file in the root directory:
# Server variables
HONO_APP_URL=http://localhost:4000
HONO_TRUSTED_ORIGINS=http://localhost:3000
# Generate using: openssl rand -base64 32
BETTER_AUTH_SECRET=your-secret-key-here
# GitHub OAuth (get from https://github.com/settings/developers)
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
# Generate at `https://console.cloud.google.com/apis/credentials`
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
# Generate using: bunx pglaunch -k
POSTGRES_URL=postgresql://user:password@localhost:5432/dbname
# Client variables
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:4000Database Setup
1. Generate Migrations
bun run db:generateThis creates migration files based on your schema in packages/db/src/schema.
2. Run Migrations
bun run db:migrateThis applies the migrations to your database.
3. (Optional) Open Drizzle Studio
bun run db:studioThis opens a visual database editor at http://localhost:4983.
Authentication Setup
ZeroStarter comes with some default authentication plugins using Better Auth, you can extend as needed.
Github
- Create a GitHub OAuth App at GitHub Developer Settings.
- Set the Homepage URL to
http://localhost:3000. - Set the Authorization callback URL to
http://localhost:3000/api/auth/callback/github. - Copy the Client ID and Client Secret into your
.envfile.
- Create a Google OAuth App in the Google Cloud Console.
- Configure the OAuth consent screen (External).
- Create an OAuth Client ID (Application type: Web).
- Set the Authorized JavaScript origins to
http://localhost:3000. - Set the Authorized redirect URI to
http://localhost:4000/api/auth/callback/google. - Copy the Client ID and Client Secret into your
.envfile.
Running the Application
Development Mode
bun devThis starts both the frontend (Next.js) and backend (Hono) servers:
- Frontend: http://localhost:3000
- Backend: http://localhost:4000
Production Build
bun run build
bun run startDocker Compose
docker compose upProject Structure
Understanding the structure helps you navigate the codebase:
.
├── api/
│ └── hono/ # Backend API (Hono)
│ ├── src/
│ │ ├── routers/ # API route definitions
│ │ └── middlewares/ # Auth & other middleware
│ └── dist/ # Compiled output
│
├── web/
│ └── next/ # Frontend (Next.js)
│ ├── src/
│ │ ├── app/ # Next.js app router pages
│ │ ├── components/ # React components
│ │ └── lib/ # Utilities & API client
│ └── content/ # MDX content (blog/docs)
│
└── packages/
├── auth/ # Shared auth logic
├── db/ # Database schema & migrations
├── env/ # Type-safe environment variables
└── tsconfig/ # Shared TypeScript configsKey Features
Type-Safe API Client
The frontend automatically gets types from your backend:
import { apiClient } from "@/lib/api/client"
// Fully typed!
const res = await apiClient.v1.health.$get()
const data = await res.json()Authentication
Use the useSession hook in your components:
import { useSession } from "@/lib/auth/client"
export function MyComponent() {
const { data: session } = useSession()
if (!session) {
return <div>Please sign in</div>
}
return <div>Welcome, {session.user.email}</div>
}Next Steps
- Customize the branding: Update
web/next/src/lib/config.ts - Add your first API route: Create routes in
api/hono/src/routers - Extend the database schema: Add tables in
packages/db/src/schema - Create pages: Add routes in
web/next/src/app - Deploy: Follow the deployment guides in the docs
Common Commands
bun dev- Start development serversbun run build- Build for productionbun run lint- Lint codebasebun run format- Format codebun run db:generate- Generate database migrationsbun run db:migrate- Run migrationsbun run db:studio- Open Drizzle Studio
Getting Help
- Check the documentation
- Review the GitHub repository
- Open an issue for bugs or feature requests
You're now ready to start building your SaaS application with ZeroStarter!