Skip to content
Docs menuSet up your modules

Set up your modules

Each module needs an account and a few keys. Pick the providers you chose in the builder and follow the steps, in this order.

Last updated November 1, 2026

Order of setup

ModuleNeeds firstEnv files
DatabaseNothingDATABASE_URL
EmailNothingEMAIL_FROM, provider key
AuthDatabase, EmailBETTER_AUTH_*
PaymentsAuth, Database, Emailprovider keys, one price per plan
StorageAuth, Database, EmailSTORAGE_PROVIDER, bucket keys
AINothing (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.

cp .env.auth.example .env

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
  1. 1
    Get a databaseUse a hosted Postgres or a local container.Your hostCreate database
  2. 2
    Copy the connection stringAdd ?sslmode=require for hosted databases.
    .env
    DATABASE_URL="postgresql://user:password@host:5432/dbname"
    DATABASE_POOL_SIZE=10
    DATABASE_POOL_TIMEOUT=20
  3. 3
    Create the tablesPush the Prisma schema, then start the app.
    npx prisma db push

Email

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
  1. 1
    Create an API keyCreate a key with sending access (resend.com/api-keys).
    .env
    RESEND_API_KEY="..."
  2. 2
    Verify your sending domainAdd your domain and the DNS records your provider shows, then wait for it to verify.ResendDomains or Sender authentication
  3. 3
    Set the senderUse an address on the verified domain.
    .env
    EMAIL_FROM="noreply@yourdomain.com"
    EMAIL_REPLY_TO="support@yourdomain.com"
    NEXT_PUBLIC_APP_URL="http://localhost:3000"
  4. 4
    Check 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
  1. 1
    Generate a secretBetter Auth signs sessions with a random secret.
    openssl rand -base64 32
  2. 2
    Set the secret and URLsUse your real domain in production.
    .env
    BETTER_AUTH_SECRET="paste-the-output-here"
    BETTER_AUTH_URL="http://localhost:3000"
    NEXT_PUBLIC_APP_URL="http://localhost:3000"
  3. 3
    Optional: 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
    .env
    Redirect URI: http://localhost:3000/api/auth/callback/google
    GOOGLE_CLIENT_ID="...apps.googleusercontent.com"
    GOOGLE_CLIENT_SECRET="..."
  4. 4
    Check it worksOpen /signup and 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
  1. 1
    Stay in test modeKeep Test mode on while you set up.dashboard.stripe.comTest mode
  2. 2
    Copy your secret keyOpen the API keys page.DevelopersAPI keys
    .env
    STRIPE_SECRET_KEY=sk_test_...
  3. 3
    Create 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
    .env
    STRIPE_PRICE_PLUS=price_...
    STRIPE_PRICE_PRO=price_...
  4. 4
    Forward 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 .env
    STRIPE_WEBHOOK_SECRET=whsec_...
  5. 5
    In productionAdd an endpoint at https://yourdomain.com/api/stripe/webhook with the events customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, customer.deleted and invoice.payment_failed, and use its signing secret.
  6. 6
    Check 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
  1. 1
    Create a private bucketKeep it private: no public access, no custom domain, no r2.dev domain.dash.cloudflare.comR2Create bucket
    .env
    STORAGE_PROVIDER=r2
    R2_BUCKET=
    R2_JURISDICTION=eu
  2. 2
    Create an API tokenObject Read & Write, limited to the bucket. Copy your account ID too.R2Manage API tokens
    .env
    R2_ACCOUNT_ID=
    R2_ACCESS_KEY_ID=
    R2_SECRET_ACCESS_KEY=
  3. 3
    Allow 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; expose ETag. Do not use a * allowed header. Paste this policy, with your own domain next to localhost:BucketSettingsCORS policy
    CORS policy
    [
    {
    "AllowedOrigins": [
    "http://localhost:3000",
    "https://domain.com"
    ],
    "AllowedMethods": [
    "GET",
    "PUT",
    "HEAD"
    ],
    "AllowedHeaders": [
    "content-type"
    ],
    "ExposeHeaders": [
    "ETag"
    ],
    "MaxAgeSeconds": 3600
    }
    ]
  4. 4
    Create 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
  1. 1
    Create 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
    .env
    AI_GATEWAY_API_KEY=
  2. 2
    Pick a modelA gateway string provider/model. No code change.
    .env
    AI_MODEL=anthropic/claude-haiku-5.5
  3. 3
    Reasoning modelsRaise the output limit: with the default 1024 a reasoning model can spend everything thinking and send no text.
    .env
    AI_MAX_OUTPUT_TOKENS=4096
  4. 4
    AttachmentsOn when Storage is installed. Tune with AI_ATTACHMENTS, AI_ATTACHMENT_TYPES (png, jpeg, webp, gif, pdf, txt, md, csv, json by default) and AI_ATTACHMENT_MAX_FILES (1 to 10). If you add Storage after AI, run npx tailar sync ai.
  5. 5
    Check it worksSign in, open /chat and send a message. The reply streams in.