Order of setup
| Module | Needs first | Env files |
|---|---|---|
| Database | Nothing | DATABASE_URL |
| Nothing | EMAIL_FROM, provider key | |
| Auth | Database, Email | BETTER_AUTH_* |
| Payments | Auth, Database, Email | provider keys, one price per plan |
| Storage | Auth, Database, Email | STORAGE_PROVIDER, bucket keys |
| AI | Nothing (Storage for attachments) | AI_* |
The CLI writes all variables, merged, to SETUP.md, and one .env.<module>.example per module. Create a .env in the project root and paste them in.
Database
Prisma with PostgreSQL, MySQL or MongoDB. Do this first: auth, payments, storage and AI threads store their data here. It adds the Prisma schema (one file per module under prisma/schema/) and a database client.
- Good for
- The default; works with any Postgres host (Neon and Supabase are common)
- Limits
- You manage backups and scaling on the host
- 1Get a databaseUse a hosted Postgres or a local container.Your hostCreate database
- 2Copy the connection stringAdd
?sslmode=requirefor hosted databases..envDATABASE_URL="postgresql://user:password@host:5432/dbname"DATABASE_POOL_SIZE=10DATABASE_POOL_TIMEOUT=20 - 3Create the tablesPush the Prisma schema, then start the app.npx prisma db push
Typed templates and a send helper, used for verification and password reset. Variables: EMAIL_FROM, EMAIL_REPLY_TO, NEXT_PUBLIC_APP_URL and one provider key.
- Good for
- Transactional email through Resend
- Limits
- Verification and reset emails depend on it: sign-in needs a verified email
- 1Create an API keyCreate a key with sending access (resend.com/api-keys)..envRESEND_API_KEY="..."
- 2Verify your sending domainAdd your domain and the DNS records your provider shows, then wait for it to verify.ResendDomains or Sender authentication
- 3Set the senderUse an address on the verified domain..envEMAIL_FROM="noreply@yourdomain.com"EMAIL_REPLY_TO="support@yourdomain.com"NEXT_PUBLIC_APP_URL="http://localhost:3000"
- 4Check it worksSign up in the app. The verification email should arrive within a minute.
Auth
Better Auth, user-based or organization-based: sign-up, login, email verification, password reset, account settings and protected routes. Organization-based adds organizations, members and invitations.
- Good for
- Email and password sign-in with required email verification, optional Google, sessions and account settings
- Limits
- You run it in your own database; there is no hosted dashboard
- Requires
- Database, Email
- 1Generate a secretBetter Auth signs sessions with a random secret.openssl rand -base64 32
- 2Set the secret and URLsUse your real domain in production..envBETTER_AUTH_SECRET="paste-the-output-here"BETTER_AUTH_URL="http://localhost:3000"NEXT_PUBLIC_APP_URL="http://localhost:3000"
- 3Optional: Google sign-inCreate an OAuth client and add the redirect URI. Email sign-in works without it.console.cloud.google.comAPIs & ServicesCredentialsCreate OAuth client ID.envRedirect URI: http://localhost:3000/api/auth/callback/googleGOOGLE_CLIENT_ID="...apps.googleusercontent.com"GOOGLE_CLIENT_SECRET="..."
- 4Check it worksOpen
/signupand create an account. Sign-in requires a verified email, so set up Email first; then sign in at/login.
Payments
Subscription plans (free, plus, pro in lib/payments/plans.ts), checkout, a customer portal and webhooks that write one provider-neutral schema. Stay in test mode until you go live.
- Good for
- Full control and the widest feature set
- Limits
- You handle sales tax and VAT yourself
- Requires
- Auth, Database, Email
- 1Stay in test modeKeep Test mode on while you set up.dashboard.stripe.comTest mode
- 2Copy your secret keyOpen the API keys page.DevelopersAPI keys.envSTRIPE_SECRET_KEY=sk_test_...
- 3Create your plansAdd a product with a recurring price for the Plus and Pro plans in
lib/payments/plans.ts. Copy each price ID.Product catalogAdd product.envSTRIPE_PRICE_PLUS=price_...STRIPE_PRICE_PRO=price_... - 4Forward webhooks while developingInstall the Stripe CLI and run this. It prints a signing secret.stripe listen --forward-to localhost:3000/api/stripe/webhook# then add to .envSTRIPE_WEBHOOK_SECRET=whsec_...
- 5In productionAdd an endpoint at
https://yourdomain.com/api/stripe/webhookwith the eventscustomer.subscription.created,customer.subscription.updated,customer.subscription.deleted,customer.deletedandinvoice.payment_failed, and use its signing secret. - 6Check it worksOpen
/choose-plan, pick a plan and pay with the test card 4242 4242 4242 4242. The plan turns active when the webhook arrives.
Storage
Private uploads with presigned URLs, owner-checked access and a files page. The bucket stays private.
- Good for
- No fee for data out; S3-compatible
- Limits
- The EU jurisdiction of a bucket cannot be changed later
- Requires
- Auth, Database, Email
- 1Create a private bucketKeep it private: no public access, no custom domain, no r2.dev domain.dash.cloudflare.comR2Create bucket.envSTORAGE_PROVIDER=r2R2_BUCKET=R2_JURISDICTION=eu
- 2Create an API tokenObject Read & Write, limited to the bucket. Copy your account ID too.R2Manage API tokens.envR2_ACCOUNT_ID=R2_ACCESS_KEY_ID=R2_SECRET_ACCESS_KEY=
- 3Allow browser uploadsUploads go straight from the browser, so the bucket needs a CORS rule for your app origin: methods GET, PUT, HEAD; allowed header
content-type; exposeETag. Do not use a*allowed header. Paste this policy, with your own domain next to localhost:BucketSettingsCORS policyCORS policy[{"AllowedOrigins": ["http://localhost:3000","https://domain.com"],"AllowedMethods": ["GET","PUT","HEAD"],"AllowedHeaders": ["content-type"],"ExposeHeaders": ["ETag"],"MaxAgeSeconds": 3600}] - 4Create the tablesPush the Prisma schema, then start the app.npx prisma db push
AI
A streaming chat at /chat built on the Vercel AI SDK, with saved threads, rate limiting and optional file attachments.
- Good for
- One key, any model, through the Vercel AI SDK. You pay the model provider through the gateway
- Limits
- Chat attachments need Storage; saved threads need the Database; sign-in protection needs Auth
- 1Create a gateway keyCreate a key at vercel.com/ai-gateway. On Vercel an OIDC token is used when the key is empty.vercel.com/ai-gateway.envAI_GATEWAY_API_KEY=
- 2Pick a modelA gateway string
provider/model. No code change..envAI_MODEL=anthropic/claude-haiku-5.5 - 3Reasoning modelsRaise the output limit: with the default 1024 a reasoning model can spend everything thinking and send no text..envAI_MAX_OUTPUT_TOKENS=4096
- 4AttachmentsOn when Storage is installed. Tune with
AI_ATTACHMENTS,AI_ATTACHMENT_TYPES(png, jpeg, webp, gif, pdf, txt, md, csv, json by default) andAI_ATTACHMENT_MAX_FILES(1 to 10). If you add Storage after AI, runnpx tailar sync ai. - 5Check it worksSign in, open
/chatand send a message. The reply streams in.