From laptop to the world
Your app works locally. Shipping it means keeping secrets out of code, building an optimised version, and running it somewhere people can reach — with the right settings for each environment.
Env vars, build, deploy
# .env.local (never committed) DATABASE_URL=postgres://user:[email protected]/cafe NEXT_PUBLIC_MAP_KEY=pk_live_123 # terminal npm run build # optimised production build npm run start # run it
- Vercel (made by the Next.js team): connect your Git repo; every push deploys, every pull request gets a preview URL.
- Self-hosting: next build && next start on any Node.js server, or the output: "standalone" Docker setup.
- Set environment variables in your host's dashboard, separately for preview and production.
- Use next/image for responsive, lazy-loaded images and next/font for self-hosted fonts with no layout shift.