Deploying an App
Writing code on your laptop is half the job. Deployment is the process of running that code on a server somewhere on the internet so other people can use it.
Environments
Most teams maintain at least three environments:
- Development — your laptop, with sample data and debug tools enabled
- Staging — a near-identical copy of production used for testing
- Production — the real version that real users hit
The same code runs in all three; what changes is configuration. That separation prevents a typo in your local setup from leaking into a customer's experience.
Environment Variables
The classic mistake is hardcoding values like database URLs or API keys into source code. Environment variables are key-value pairs the operating system exposes to your process. Your code reads them at startup, so the same binary behaves differently depending on the environment. The example reads APP_ENV, PORT, and DATABASE_URL, which is what nearly every real app does.
Secrets (API tokens, passwords) never belong in the repo. Use a secret manager or your platform's environment variable UI.
Build vs Runtime
Many languages have a build step: compile, bundle, minify. The output is a static artifact (a binary, a folder of HTML/JS/CSS, a Docker image) that you deploy. Runtime is when that artifact is actually executing on a server. Build-time errors stop the deploy; runtime errors crash a single request. Making this distinction explicit helps you reason about where to catch problems.
Deployment Platforms
You have three broad choices:
- Static hosts (Netlify, Vercel, GitHub Pages) — perfect for frontends. Push code, they build and serve it.
- Platform-as-a-Service (Heroku, Render, Fly.io) — give them a backend, they handle the server, scaling, and deploys.
- Cloud infrastructure (AWS, GCP, Azure) — full control, full responsibility. Usually wrapped with Docker and orchestrated with Kubernetes for larger systems.
Start with the simplest option that works.
Try It Yourself
- Set a local
APP_ENV=productionvariable and watch the example switch behavior - List three values that should live in env vars rather than your repo
- Sketch what a build step does for a React app vs a Python web service