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
- Test the code: manually and with automated tests.
- Optimize the code: lazy loading (Entries 2–5), removing unused code and dependencies.
- Build for production:
npm run buildcreates minified, bundled files (Entry 6). - Upload the files: to a static host (Entry 8).
- 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
| Step | React (Vite) | Angular CLI |
|---|---|---|
| Build | npm run build | ng build |
| Output | dist/ | dist/<project>/browser/ |
| Lazy loading | lazy(), import(), route lazy | loadComponent, loadChildren, @defer |
| Hosting | Any static host | Any static host |