Deploying Blitz.js Apps
Zero-API full-stack React framework with RPC, deploy to Vercel or self-hosted Node.
PlatformsAdvanced
Why
Blitz.js eliminates API boilerplate with its zero-API layer — you import server functions directly in components. Built on Next.js, it inherits all deploy options while adding Prisma and auth.
When
Use Blitz for full-stack React apps wanting Next.js + Prisma + auth without writing APIs. Avoid if you need a separate API for mobile clients.
How
1. Build — blitz build, wraps Next.js build
2. Vercel — blitz start --production or git push
3. Self-host — blitz build && blitz start --production
4. DB — blitz prisma migrate deploy
5. RPC — "use server" functions auto-become RPC endpoints
Example
// app/users/queries/getUsers.ts — zero-API RPC
import { db } from "db";
export default async function getUsers() {
"use server";
return db.user.findMany();
}
// Deploy: blitz build && vercel --prod
Common Problems
- ⚠RPC function runs on client — forgot 'use server' directive
- ⚠Prisma client not generated — run blitz prisma generate before build
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use Blitz auth middleware for route protection — built-in session management
- ✓Keep RPC functions in queries/mutations folders — convention enables auto-routing
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit