Web Development · Module 13 · Lesson 11 min read

Deploying Your Website

From your laptop to the world

You builtDeploy toHow
Plain HTML/CSS/JSGitHub Pages, Netlify, Vercel, Cloudflare Pagespush to GitHub, connect the repo
React/Vite appNetlify, Vercel, Cloudflare Pagesbuild command npm run build, output folder dist
Next.js appVercel (or any Node host)connect the repo
Node/Express APIRender, Railway, Fly.iostart command node index.js, set env vars
Database + authSupabasealready hosted

The usual flow

  1. Push your code to GitHub.
  2. In the hosting dashboard, import the repository.
  3. Set the build command and output directory.
  4. Add environment variables (never commit them).
  5. Deploy. After that, every push to main deploys again automatically, and Pull Requests get preview links.

Custom domains

Buy a domain, then add the DNS records your host gives you (usually an A record or a CNAME). HTTPS certificates are created automatically.

Single-page apps and routing

For React Router apps on static hosts, add a rewrite so every path serves index.html (Netlify: _redirects with /* /index.html 200), or refreshing a sub-page gives a 404.

After launch

  • Check the live site on a real phone.
  • Run Lighthouse.
  • Add error monitoring (Sentry) and analytics.

Example

Terminal
# Deploy a Vite/React site to Netlify with the CLI
npm install -g netlify-cli
npm run build
netlify deploy --prod --dir=dist

# Or Vercel
npm install -g vercel
vercel --prod

# React Router fix for Netlify (public/_redirects):
# /*   /index.html   200

# Express API on Render:
#   Build command:  npm install
#   Start command:  node index.js
#   Environment:    DATABASE_URL, JWT_SECRET, FRONTEND_URL
# 💻 Run on a computer