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
process.env.API_KEY is undefinedFetch failed - API_URL is nullTypeError: 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.

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. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too Victor Denisov Victor Denisov Developer Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software. 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.

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