AIAI SaaS

Deployment

Ship to Vercel in one command; Cloudflare notes included.

npx vercel login
npx vercel link --yes
# add env vars: vercel env add NAME production
npx vercel deploy --prod

Add your custom domain in the Vercel dashboard and point DNS (a CNAME is suggested automatically). Set NEXT_PUBLIC_SITE_URL and BETTER_AUTH_URL to the final domain before the production build.

Cloudflare Workers

The OpenNext toolchain is wired (pnpm run preview / deploy), with Windows compatibility patches applied automatically on pnpm install. Note: the free Workers plan caps scripts at 3 MiB — this template needs the paid plan ($5/mo).

After deploying

  1. Point Stripe webhooks to https://your-domain/api/stripe/webhook and set STRIPE_WEBHOOK_SECRET
  2. Update OAuth redirect URIs (Google/GitHub) to the new domain
  3. Schedule the daily credits job: GitHub Actions secret DATABASE_URL, or cron-job.org hitting /api/distribute-credits with basic auth

Database migrations

pnpm db:generate   # after schema edits
pnpm db:migrate    # apply