Module 7 · Lesson 4

Deploying an App

From localhost to the internet: environments, environment variables, and deployment platforms.

Audio: Deploying an App
0:000:00

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=production variable 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

Code Playground

Edit the code below and click Run to see the output. Switch between languages using the tabs.

Loading editor...

Enjoying the lesson? Unlock the full Full-Stack Web Development from $4.99/mo.

See plans →