Deploying React AppsEntry 1 of 11

Deployment Steps

Deploying turns the development app into optimized static files and puts them on a server where users can reach them.

Notes

  1. Test the code: manually and with automated tests.
  2. Optimize the code: lazy loading (Entries 2–5), removing unused code and dependencies.
  3. Build for production: npm run build creates minified, bundled files (Entry 6).
  4. Upload the files: to a static host (Entry 8).
  5. Configure the server: rewrites for client-side routing (Entry 9), HTTPS, caching.
  • A React SPA built with Vite is a static site: HTML, CSS, and JavaScript. No Node server is needed to serve it.
  • Frameworks with server rendering (Next.js, React Router framework mode) need a server and deploy differently.

What / Why / When

What

The path from source code to a live URL.

Why

Development builds are large, slow, and include debugging tools.

When

Every release.

Angular

The same steps apply: test, optimize (lazy routes, @defer), ng build, upload dist/<project>/browser, configure rewrites. Angular apps with SSR (@angular/ssr) need a Node server.

Quick reference

StepReact (Vite)Angular CLI
Buildnpm run buildng build
Outputdist/dist/<project>/browser/
Lazy loadinglazy(), import(), route lazyloadComponent, loadChildren, @defer
HostingAny static hostAny static host