Bolt deployment

Environment Variables Not Loading - Undefined in Build

Environment variables are undefined in your deployed application even though they're set in the platform. API keys, database URLs, and other config values come back as undefined.

Variables work fine locally but disappear after deployment.

Error Messages You Might See

process.env.API_KEY is undefined Fetch failed - API_URL is null TypeError: Cannot read property 'split' of undefined

Common Causes

  1. Using process.env.VAR instead of NEXT_PUBLIC_VAR for client-side access
  2. Environment variables set after build completes
  3. Wrong environment selected in deployment platform (staging vs production)
  4. Variable name mismatch between code and platform settings
  5. Quotes or special characters in env var value causing parsing issues

How to Fix It

For client-side vars: prefix with NEXT_PUBLIC_ (e.g., NEXT_PUBLIC_API_URL)

For server-side only: use plain process.env.PRIVATE_VAR (won't leak to browser)

Set env vars BEFORE triggering redeploy in your platform

Test locally: create .env.local with same vars and run npm run build

Real developers can help you.

Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Matt Butler Matt Butler Software Engineer @ AWS Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's the difference between .env and .env.local?

.env is version controlled, .env.local is git-ignored. Use .env.local for secrets locally

How do I set env vars in Vercel?

Settings > Environment Variables. Make sure you set them before deploying

Should secrets use NEXT_PUBLIC_?

NO! Use NEXT_PUBLIC_ only for public values. Secrets stay as plain process.env.VAR and are only available on server

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help