0
Challenge · 79Tooling & Quality
Environment Variables
Toolused in ~80% of apps
Hard-code your API URL and you ship one frozen app: the same address in dev, staging, and prod, and your Stripe key sitting in a public repo. Environment variables let one codebase read different values per environment — and, critically, let you keep secrets out of the bundle every visitor downloads.
Core idea. An environment variable is a named value supplied from outside your code (a .env file or the host) that your build tool reads at build time. Only variables with the public prefix (VITE_ / NEXT_PUBLIC_) are inlined into the client bundle; everything else stays server-side and never reaches the browser.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
.envgit-ignored
Tap a line to toggle its VITE_ prefix. P = public, S = server-only.
app.4f2.jsSHIPPED TO BROWSER · PUBLIC
import.meta.env.VITE_API_BASE_URL // → "https://api.pulse.app"
server (process.env)NEVER SENT TO BROWSER
ANALYTICS_ID // stays here, value hidden from users
DATABASE_URL // stays here, value hidden from users
STRIPE_SECRET_KEY // stays here, value hidden from users
Safe build. Only the public URL/id were prefixed and inlined; the real secrets stayed on the server. The rule: a prefix makes a value public forever, so only ever prefix things you would print on a billboard.
↑ play a little first, then dig in