Skip to main content

Environment Variables

Frontend apps handle environment variables quite differently from server-side apps. The reason is simple. Frontend apps run in the browser. The browser has no concept of environment variables.

Variables at Build Time

One option is to set environment variables at build time on the build machine. The bundler then uses these values. It replaces them in the client bundles it builds.

danger

This approach has a problem. Say you plan to run the app in many environments. Then you must build the app once for each environment. And if you ship docker images, you must build one image per environment.