next-forge
Original:🇺🇸 English
Not Translated
next-forge expert guidance — production-grade Turborepo monorepo SaaS starter by Vercel. Use when working in a next-forge project, scaffolding with `npx next-forge init`, or editing @repo/* workspace packages.
1installs
Sourcevercel/vercel-plugin
Added on
NPX Install
npx skill4agent add vercel/vercel-plugin next-forgeSKILL.md Content
next-forge
next-forge is a production-grade Turborepo template for building Next.js SaaS applications. It provides a monorepo structure with multiple apps, shared packages, and integrations for authentication, database, payments, email, CMS, analytics, observability, security, and more.
Quick Start
Initialize a new project:
bash
npx next-forge@latest initThe CLI prompts for a project name and package manager (bun, npm, yarn, or pnpm). After installation:
- Set the in
DATABASE_URLpointing to a PostgreSQL database (Neon recommended).packages/database/.env - Run database migrations:
bun run migrate - Add any optional integration keys to the appropriate files.
.env.local - Start development:
bun run dev
All integrations besides the database are optional. Missing environment variables gracefully disable features rather than causing errors.
Architecture Overview
The monorepo contains apps and packages. Apps are deployable applications. Packages are shared libraries imported as .
@repo/<package-name>Apps (in ):
/apps/| App | Port | Purpose |
|---|---|---|
| 3000 | Main authenticated SaaS application |
| 3001 | Marketing website with CMS and SEO |
| 3002 | Serverless API for webhooks, cron jobs |
| 3003 | React Email preview server |
| 3004 | Documentation site (Mintlify) |
| 6006 | Design system component workshop |
| 3005 | Prisma Studio for database editing |
Core Packages: , , , , , , , , , , , , , , , , , , , , .
authdatabasepaymentsemailcmsdesign-systemanalyticsobservabilitysecuritystorageseofeature-flagsinternationalizationwebhookscronnotificationscollaborationairate-limitnext-configtypescript-configFor detailed structure, see .
references/architecture.mdKey Concepts
Environment Variables
Environment variable files live alongside apps and packages:
- — Main app keys (Clerk, Stripe, etc.)
apps/app/.env.local - — Marketing site keys
apps/web/.env.local - — API keys
apps/api/.env.local - —
packages/database/.env(required)DATABASE_URL - — BaseHub token
packages/cms/.env.local - — Languine project ID
packages/internationalization/.env.local
Each package has a file that validates environment variables with Zod via . Type safety is enforced at build time.
keys.ts@t3-oss/env-nextjsInter-App URLs
Local URLs are pre-configured:
NEXT_PUBLIC_APP_URL=http://localhost:3000NEXT_PUBLIC_WEB_URL=http://localhost:3001NEXT_PUBLIC_API_URL=http://localhost:3002NEXT_PUBLIC_DOCS_URL=http://localhost:3004
Update these to production domains when deploying (e.g., , ).
app.yourdomain.comwww.yourdomain.comServer Components First
page.tsxlayout.tsx'use client'Graceful Degradation
All integrations beyond the database are optional. Clients use optional chaining (e.g., , ). If the corresponding environment variable is not set, the feature is silently disabled.
stripe?.prices.list()resend?.emails.send()Common Tasks
Running Development
bash
bun run dev # All apps
bun dev --filter app # Single app (port 3000)
bun dev --filter web # Marketing site (port 3001)Database Migrations
After changing :
packages/database/prisma/schema.prismabash
bun run migrateThis runs Prisma format, generate, and db push in sequence.
Adding shadcn/ui Components
bash
npx shadcn@latest add [component] -c packages/design-systemUpdate existing components:
bash
bun run bump-uiAdding a New Package
Create a new directory in with a using the naming convention. Add it as a dependency in consuming apps.
/packages/package.json@repo/<name>Linting and Formatting
bash
bun run lint # Check code style (Ultracite/Biome)
bun run format # Fix code styleTesting
bash
bun run test # Run tests across monorepoBuilding
bash
bun run build # Build all apps and packages
bun run analyze # Bundle analysisDeployment
Deploy to Vercel by creating separate projects for , , and — each pointing to its respective root directory under . Add environment variables per project or use Vercel Team Environment Variables.
appwebapi/apps/For detailed setup and customization instructions, see:
- — Installation, prerequisites, environment variables, database and Stripe CLI setup
references/setup.md - — Detailed documentation for every package
references/packages.md - — Swapping providers, extending features, deployment configuration
references/customization.md - — Full monorepo structure, Turborepo pipeline, scripts
references/architecture.md