Deploy to Netlify
Netlify Functions for on-demand routes, the Image CDN for images and static headers for prerendered pages.
-
Import the repository at app.netlify.com.
netlify.tomlsets the build command (pnpm build), the publish directory (dist) andNODE_VERSION=24. Netlify setsNETLIFY=true, which selects the adapter. -
Add the environment variables from
.env.examplein Site configuration → Environment variables (ornetlify env:set). SetSITE_URLandBETTER_AUTH_URLto your production domain. -
Create the tables: add
DATABASE_URLandDATABASE_AUTH_TOKENas GitHub Actions secrets and run the Migrate database workflow (see the database guide). Netlify’s environment variables are not visible to GitHub Actions. Until the workflow has run, sign-up and the contact form fail because the tables do not exist. -
Set the functions runtime to Node 24 by adding
AWS_LAMBDA_JS_RUNTIME=nodejs24.xas an environment variable. This value cannot be set innetlify.toml. -
Deploy. Deploy previews are trusted by Better Auth automatically through
DEPLOY_PRIME_URL.
What the adapter configures#
netlify({ staticHeaders: true });
- Static headers deliver the CSP for prerendered pages through Netlify’s configuration.
- Netlify Image CDN optimises
<Image>on the fly; remote domains must be listed inimage.domainsorimage.remotePatterns. - Netlify Blobs are available if you enable Astro sessions.
- Skew protection is configured automatically for actions and server islands.
Security headers for static assets come from public/_headers, which Netlify reads from the
publish directory. On-demand responses get them from src/middleware.ts.
Local development#
The adapter emulates the Image CDN, Blobs and edge context during pnpm dev once you link the
site with netlify link. Nothing else is required.
Netlify CLI#
The Netlify CLI is not a dependency of the template, so run it through pnpm dlx:
pnpm build:netlify
pnpm dlx netlify-cli deploy --prod