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.

Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Victor Denisov Victor Denisov Developer prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Alvin Voo Alvin Voo I’ve watched the tech landscape evolve over the last decade—from the structured days of Java Server Pages to the current "wild west" of Agentic-driven development. While AI can "vibe" a frontend into existence, I specialize in the architecture that keeps it from collapsing. My expertise lies in the critical backend infrastructure: the parts that must be fast, secure, and scalable. I thrive on high-pressure environments, such as when I had only three weeks to architect and launch an Ethereum redemption system with minimal prior crypto knowledge, turning it into a major revenue stream. What I bring to your project: Forensic Debugging: I don't just "patch" bugs; I use tools like Datadog and Explain Analyzers to map out bottlenecks and resolve root causes—like significantly reducing memory usage by optimizing complex DB joins. Full-Stack Context: Deep experience in Node.js and React, ensuring backends play perfectly with mobile and web teams. Sanity in the Age of AI: I bridge the gap between "best practices" and modern speed, ensuring your project isn't just built fast, but built to last. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Matt Butler Matt Butler Software Engineer @ AWS Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert

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