CSR vs SSR

Overview
React (CSR) Flow
- Initial Server Response
<!DOCTYPE html>
<html>
<head>...</head>
<body>
<div id="root"></div>
<script src="/static/js/bundle.js"></script>
</body>
</html>
- Subsequent Requests
Browser requests JavaScript bundles (usually split into chunks):
main.chunk.js (application code)
vendor.chunk.js (dependencies)
runtime.js (webpack runtime)
All static files served from
/build
directoryClient-side rendering begins only after JS loads
Data fetching starts after JS execution
Next.js (SSR) Flow
- Initial Server Response
<!DOCTYPE html>
<html>
<head>
<script src="/_next/static/chunks/main.js" defer></script>
</head>
<body>
<div id="__next">
<!-- Fully populated HTML content -->
<!-- Server Component Payload -->
</div>
</body>
</html>
- File Structure After Build
.next/
├── server/
│ ├── pages/
│ │ └── [page].html
│ └── chunks/
├── static/
│ ├── chunks/
│ ├── css/
│ └── media/
Key Differences in File Serving
React (CSR)
Serves static files from single build directory
Initial HTML is empty
Requires complete JS load for any content display
All routing handled client-side
Next.js (SSR)
Serves from
.next
directory with specialized structureInitial HTML contains full content
JS files load for hydration but content visible first
Server handles routing and generates specific HTML per route
Performance Implications
React: Larger initial JavaScript bundle, slower first contentful paint
Next.js: Faster first contentful paint, smaller initial JS payload, better SEO
Browser Processing Order
React:
- Empty HTML → 2. JS Bundles → 3. Render Content → 4. Data Fetching
Next.js:
- Full HTML → 2. Display Content → 3. JS for Hydration → 4. Interactive
This comprehensive approach shows why Next.js typically provides better initial load performance and SEO capabilities, while React's CSR approach might be more suitable for highly interactive applications where initial load time is less critical.
Subscribe to my newsletter
Read articles from Sam directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
