Skip to content
Strata

Deploy to Vercel

Zero-configuration deployment to Vercel with Node 24 functions, static headers and image optimisation.

Vercel is the primary deployment target for this repository.

  1. Import the repository at vercel.com/new. Vercel detects Astro and pnpm automatically. Leave the build command as astro build; DEPLOY_TARGET is inferred from VERCEL=1.

  2. Add the environment variables from .env.example in Project → Settings → Environment Variables. At minimum: DATABASE_URL, DATABASE_AUTH_TOKEN, BETTER_AUTH_SECRET and BETTER_AUTH_URL (a full URL such as https://my-site.vercel.app). If you add Turso through the Vercel Marketplace it sets TURSO_DATABASE_URL and TURSO_AUTH_TOKEN instead, which the template reads as well. SITE_URL is optional: when it is unset the build uses the production URL Vercel injects (VERCEL_PROJECT_PRODUCTION_URL). None of these variables are needed to build, so you can also add them after the first deployment and redeploy.

  3. Create the tables: add the database URL and token as GitHub Actions secrets (DATABASE_URL and DATABASE_AUTH_TOKEN, or the same TURSO_* names the integration uses) and run the Migrate database workflow (see the database guide). Vercel’s environment variables are not visible to GitHub Actions, so the secrets must be added in the repository even when the integration already set them on Vercel. Until the workflow has run, sign-up and the contact form fail because the tables do not exist.

  4. Deploy. Every pull request gets a preview deployment; preview hostnames are trusted by Better Auth automatically through VERCEL_URL and VERCEL_BRANCH_URL.

What the adapter configures#

vercel({ imageService: true, staticHeaders: true });
  • Node version. Vercel reads "engines": { "node": "24.x" } from package.json.
  • Static headers. The Content Security Policy for prerendered pages is written to the Build Output configuration instead of a <meta> tag.
  • Security headers. integrations/security-headers.ts prepends a route to .vercel/output/config.json that applies the headers from config/security-headers.ts to every path.
  • Images. <Image> and <Picture> use Vercel Image Optimization at runtime.

Optional extras#

  • Enable Vercel Web Analytics by setting PUBLIC_ANALYTICS=vercel; the @vercel/analytics Astro component is rendered only when this is set, and its beacons are same-origin so the CSP needs no change.
  • Turn on ISR for on-demand pages with vercel({ isr: { expiration: 60 } }) if you add server-rendered pages that can be cached.
  • Store the database with the Turso integration from the Vercel Marketplace, which injects TURSO_DATABASE_URL and TURSO_AUTH_TOKEN; no renaming is needed.

Custom domains#

After adding a domain in Vercel, VERCEL_PROJECT_PRODUCTION_URL switches to it automatically. Update BETTER_AUTH_URL and siteConfig.url (or set SITE_URL), then redeploy so canonical links, the sitemap and OAuth callback URLs use the final host.