ChaiBuilder Logo

Deploy to Netlify

Netlify runs Next.js apps through its Next.js runtime, which is applied automatically when you import the repository - server rendering, ISR, and image optimization work without custom configuration. The starter deploys to Netlify without code changes.

1. Prepare production services

Same as any serverless target:

  • A remote database. Netlify functions are ephemeral - a local SQLite file will not work. Use Turso (libSQL) or a Postgres provider (Neon, Supabase), connected through the provider's pooled endpoint. See Database Setup.
  • Object storage. Uploads need an S3-compatible bucket - see Storage Configuration.

2. Import the project

  1. Push your project to a Git repository.
  2. In Netlify, Add new site → Import an existing project and pick the repository.
  3. Netlify detects Next.js and applies its Next.js runtime. The defaults are correct; if asked, the build command is pnpm run build and the publish directory is .next.

3. Set environment variables

In Site configuration → Environment variables, add the production values:

DATABASE_URL=postgresql://…        # pooled connection string
PAYLOAD_SECRET=…                   # long random secret
CHAIBUILDER_APP_KEY=…              # from your generated .env
SITE_URL=https://www.example.com   # your primary domain
CHAIBUILDER_LICENSE_KEY=…          # optional during trial

# Object storage
BUCKET_NAME=…
AWS_ACCESS_KEY_ID=…
AWS_SECRET_ACCESS_KEY=…
S3_REGION=…                        # defaults to "auto" when unset
S3_ENDPOINT=…                      # omit on AWS S3

Unlike Vercel, there is no platform variable the app picks up for the site's base URL - set SITE_URL explicitly to your primary domain. The full variable reference is in Environment & License.

4. Deploy

Trigger the first deploy, then verify the usual three things:

  • The site, builder, and admin panel load on the site URL.
  • Publish a page and confirm the change is visible without a redeploy.
  • Upload an image and confirm it renders and lands in your bucket.

Pushes to the production branch deploy automatically; other branches get Deploy Previews with their own URLs.

How the rendering model maps to Netlify

  • Pages are built on first visit by a server function and cached by the runtime's incremental cache, fronted by Netlify's CDN.
  • Publishing revalidates the affected paths and tags - the next visitor gets the new version, no rebuild. Details in Caching & Revalidation.
  • A new deploy starts with a fresh cache; pages rebuild lazily on first visit.

Notes and limits

  • Build memory - the starter's build script raises the Node heap limit; if a build is killed, check the deploy log for out-of-memory and raise the build resources on your plan.
  • Function timeouts - normal renders are fast; first-visit builds of heavy pages and AI-assisted operations benefit from higher function timeout limits on paid plans.
  • Custom domain - add your domain in Netlify's domain settings and keep SITE_URL in sync with it, since licensing validates against your domain.

© ChaiBuilder. All rights reserved.