Deploy & ShipBeginner-friendly

Environment Variables Explained for Non-Technical Founders

What environment variables are, why they matter, and how to set them up correctly. No jargon, just practical guidance.

What are environment variables?

Environment variables are configuration values that change between environments (development, staging, production). Instead of hardcoding your database URL or API key directly in your code, you store it in an environment variable. This keeps secrets out of your codebase and lets the same code run with different configurations.

Why they matter

If your API keys are in your code (and your code is on GitHub), anyone can find and use them. Environment variables keep secrets separate from code. They also let you use different databases, API endpoints, and settings for development vs production without changing code.

How they work in practice

In development, you create a .env.local file (which is NOT committed to Git) with your values: DATABASE_URL=postgresql://... and API_KEY=sk-123... Your code reads these with process.env.DATABASE_URL. In production, you set these same values in your hosting platform's dashboard. The code stays the same — only the values change.

Public vs private variables

In Next.js, variables prefixed with NEXT_PUBLIC_ are exposed to the browser — anyone can see them in the page source. Only use this prefix for values that are safe to be public, like your Supabase project URL. Everything else (database passwords, API secret keys, webhook secrets) should be server-only — no NEXT_PUBLIC_ prefix. In Vite, the equivalent prefix is VITE_.

Setting up environment variables

Step 1: Create a .env.local file in your project root. Step 2: Add .env.local to your .gitignore (so it's never committed). Step 3: Add all configuration values to this file. Step 4: In your hosting platform (Vercel, Netlify, Railway), add the same variables in the project settings. Step 5: Create a .env.example file (committed to Git) listing every required variable with placeholder values, so anyone setting up the project knows what's needed.

Need help with this?

Our team handles deploy & ship for AI-built apps every day. Get a fixed quote within 24 hours.

Start with a self-serve audit

Get a professional review of your app at a fixed price.

Security Scan

Black-box review of your public-facing app. No code access needed.

$19
  • OWASP Top 10 checks
  • SSL/TLS analysis
  • Security headers
  • Expert review within 24h
Get Started

Code Audit

In-depth review of your source code for security, quality, and best practices.

$19
  • Security vulnerabilities
  • Code quality review
  • Dependency audit
  • AI pattern analysis
Get Started
Best Value

Complete Bundle

Both scans in one package with cross-referenced findings.

$29$38
  • Everything in both products
  • Cross-referenced findings
  • Unified action plan
Get Started

100% credited toward any paid service. Start with an audit, then let us fix what we find.

Related technologies

Need help with your app?

Tell us about your project. We'll respond within 24 hours with a clear plan and fixed quote.

Tell Us About Your App