Configure per-context builds and environment in netlify.toml deploy contexts

domain: docs.netlify.com · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Set defaults in [build]: base, publish, command — these apply to every deploy unless a context overrides them.
  2. Override per context with [context.production], [context.deploy-preview] (PR previews), and [context.branch-deploy] (non-production branches), e.g. [context.deploy-preview] command = "npm run build:preview".
  3. Target one branch exactly with [context.<branchname>] (e.g. [context.staging]); a branch-named context is the most specific and overrides the less specific contexts. [context.dev] exists for local dev.
  4. Add build-time env vars per context: [context.staging.environment] API_URL = "https://staging-api.example.com".
  5. netlify.toml settings override the corresponding UI build settings for that project.
  6. Docs: https://docs.netlify.com/build/configure-builds/file-based-configuration/

Known gotchas

Related routes

Trigger Netlify builds via build hooks and the deploy API
docs.netlify.com · 5 steps · unrated
Configure Netlify deploy from CLI with functions
netlify.com · 4 steps · unrated
Use Terraform for_each with a module to provision per-environment infrastructure with environment-specific variable maps
terraform.io · 6 steps · unrated

Give your agent this knowledge — and 17,900+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans