Skip to content

sandeepmshetty/page-rendering-demo

Repository files navigation

Page Rendering Demo πŸš€

Live Demo GitHub Next.js TypeScript

A comprehensive, interactive demonstration of different page rendering strategies in modern web development using Next.js 14. This project goes beyond basic examples to show real HTML/JavaScript differences, performance metrics, and technical deep dives for each rendering approach.

✨ What Makes This Demo Special

  • πŸ” Technical Deep Dives: See actual HTML source code, bundle analysis, and rendering timelines
  • πŸ“Š Performance Metrics: Real TTFB, FCP, LCP, and TTI comparisons
  • 🎨 Visual Demonstrations: Each rendering method uses technique-specific styling approaches
  • ⚑ Interactive Examples: Live cache states, loading demonstrations, and state management
  • πŸ“š Educational Content: Comprehensive explanations, use cases, and best practices

🌐 Live Demo

Experience all rendering strategies live with:

  • Interactive demos of CSR, SSR, SSG, and ISR
  • Real-time performance metrics and bundle analysis
  • Technical deep dives with actual HTML source code
  • Live cache state visualization for ISR

Local Development: Visit http://localhost:3000 after setup

πŸ“– Rendering Methods Demonstrated

πŸ”„ Client-Side Rendering (CSR)

  • Route: /csr
  • Key Features:
    • Live JavaScript bundle analysis (~250KB React + ~45KB components)
    • Initial HTML vs. final DOM comparison
    • State management demonstration with real-time updates
    • Performance timeline showing 4-stage rendering process
  • Best For: Interactive dashboards, user-specific content, SPAs
  • Performance: Fast navigation, slower initial load (TTI ~2100ms)

πŸ–₯️ Server-Side Rendering (SSR)

  • Route: /ssr
  • Key Features:
    • Generated HTML source code display
    • Server vs. client processing breakdown
    • Request flow visualization with unique request IDs
    • Critical CSS inlining demonstration
  • Best For: Dynamic content, SEO-critical pages, personalized content
  • Performance: Balanced approach (FCP ~300ms, server-dependent)

πŸ“„ Static Site Generation (SSG)

  • Route: /ssg
  • Key Features:
    • Build vs. runtime comparison table
    • Generated static file structure visualization
    • Build-time CSS computation examples
    • Static optimization demonstrations
  • Best For: Blogs, marketing pages, documentation, high-traffic sites
  • Performance: Fastest loading (FCP ~100ms, CDN-served)

⚑ Incremental Static Regeneration (ISR)

  • Route: /isr
  • Key Features:
    • Live cache state visualization (Fresh/Stale-Revalidating/Fallback)
    • 5-step revalidation lifecycle demonstration
    • Real-time cache status with adaptive styling
    • Comparison table with other rendering strategies
  • Best For: E-commerce, news sites, content that updates periodically
  • Performance: Best of both worlds (Static speed + fresh content)

πŸ› οΈ Technologies Used

  • Next.js 14 - React framework with App Router and server components
  • TypeScript - Full type safety across all components
  • Tailwind CSS - Utility-first styling with custom animations
  • React 18 - Server and client components with modern patterns
  • PostCSS - CSS processing and optimization

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm, yarn, pnpm, or bun

Installation

# Clone the repository
git clone https://github.com/sandeepmshetty/page-rendering-demo.git
cd page-rendering-demo

# Install dependencies
npm install

# Start development server
npm run dev

# Open your browser
open http://localhost:3000

Available Scripts

npm run dev      # Start development server (port 3000)
npm run build    # Build for production
npm run start    # Start production server
npm run lint     # Run ESLint

πŸš€ Deployment

This project is deployed on Vercel for optimal performance and global edge distribution.

Deployment Features

  • βœ… Automatic deployments from main branch
  • 🌐 Global CDN for fastest loading worldwide
  • ⚑ Edge functions for optimal SSR performance
  • πŸ“Š Real-time analytics and performance monitoring
  • πŸ”’ HTTPS enabled by default

Deploy Your Own

Deploy with Vercel

  1. Fork this repository
  2. Connect to Vercel via GitHub
  3. Deploy automatically with zero configuration
  4. Explore all rendering strategies live!

Other Deployment Options

  • Netlify: Works out of the box with npm run build
  • AWS Amplify: Full SSR support with serverless functions
  • Railway: Simple deployment with automatic HTTPS
  • Self-hosted: Use npm run build && npm run start

πŸ“ Enhanced Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ layout.tsx              # Root layout with enhanced navigation
β”‚   β”œβ”€β”€ page.tsx                # Landing page with method comparisons
β”‚   β”œβ”€β”€ globals.css             # Global styles and animations
β”‚   β”œβ”€β”€ csr/
β”‚   β”‚   └── page.tsx            # CSR with bundle analysis & state demo
β”‚   β”œβ”€β”€ ssr/
β”‚   β”‚   └── page.tsx            # SSR with HTML source & request flow
β”‚   β”œβ”€β”€ ssg/
β”‚   β”‚   └── page.tsx            # SSG with build process visualization
β”‚   └── isr/
β”‚       └── page.tsx            # ISR with cache lifecycle demo
β”œβ”€β”€ components/
β”‚   └── Navigation.tsx          # Enhanced navigation with active states
β”œβ”€β”€ next.config.js              # Next.js configuration
β”œβ”€β”€ tailwind.config.ts          # Tailwind customization
β”œβ”€β”€ tsconfig.json               # TypeScript configuration
└── postcss.config.js           # PostCSS setup

πŸ” Technical Implementation Highlights

CSR Deep Dive Features

'use client'
// Real-time state management demonstration
// JavaScript bundle breakdown visualization
// Initial HTML vs. rendered DOM comparison
// 4-stage rendering timeline with performance metrics

SSR Technical Details

// Server-generated HTML with inline styles
const sampleGeneratedHTML = `<!-- Complete HTML structure -->`
// Request flow diagram with timestamps
// Server vs. client processing breakdown

SSG Build Process

export const dynamic = 'force-static'
// Build-time CSS computation examples  
// Static file structure visualization
// Performance comparison tables

ISR Cache Management

export const revalidate = 60
// Live cache state visualization
// 5-step revalidation lifecycle
// Adaptive styling based on cache status

οΏ½ Performance Analysis

Detailed Metrics Comparison

Method TTFB FCP LCP TTI Bundle Size Server Load SEO Score
CSR ~50ms ~800ms ~2000ms ~2100ms ~310KB Low ⭐ Poor ❌
SSR ~200ms ~300ms ~400ms ~500ms ~45KB High ❌ Excellent βœ…
SSG ~20ms ~100ms ~150ms ~200ms ~45KB None ⭐ Excellent βœ…
ISR ~50ms ~120ms ~200ms ~250ms ~45KB Low ⭐ Excellent βœ…

Use Case Decision Matrix

Scenario Recommended Method Why?
Blog/Documentation SSG Static content, fastest loading
E-commerce Product Pages ISR Static speed + inventory updates
User Dashboard CSR Highly interactive, personalized
News Website SSR/ISR Fresh content + SEO requirements
Marketing Landing Page SSG Performance critical, static content

🎯 Learning Outcomes

After exploring this demo, you'll master:

βœ… When to use each rendering strategy with real-world examples
βœ… Performance implications with actual metrics and timelines
βœ… SEO considerations and search engine optimization strategies
βœ… Next.js 14 implementation patterns with App Router
βœ… Bundle optimization and JavaScript delivery strategies
βœ… Cache management and revalidation strategies
βœ… Server vs. client processing trade-offs

πŸ”§ Advanced Features

Interactive Demonstrations

  • Live Bundle Analysis: See JavaScript bundle sizes and composition
  • Cache State Visualization: Watch ISR cache states change in real-time
  • Performance Timelines: Visual representation of rendering stages
  • HTML Source Comparison: Side-by-side initial vs. final markup

Educational Components

  • Request Flow Diagrams: Visual representation of each rendering process
  • Performance Metrics: Real-time TTFB, FCP, LCP measurements
  • Code Examples: Actual implementation code for each strategy
  • Best Practice Guidance: When and why to use each approach

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository on GitHub
  2. Clone your fork locally
  3. Create a feature branch (git checkout -b feature/amazing-feature)
  4. Make your changes with appropriate tests
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request with a clear description

Development Guidelines

  • Follow TypeScript best practices
  • Maintain consistent code formatting
  • Add comments for complex logic
  • Test all rendering methods thoroughly

πŸ“œ License

This project is open source and available under the MIT License.

πŸ”— Additional Resources

Official Documentation

Performance & SEO

Styling & UI

🏷️ Tags

next.js react typescript rendering performance seo ssr ssg csr isr web-vitals tailwind-css javascript frontend education demo


⭐ If this demo helped you understand rendering strategies, please star the repository!

πŸ› Found an issue? Open an issue
πŸ’‘ Have a suggestion? Start a discussion

git clone <repository-url>
cd Page-Rendering-Demo
  1. Install dependencies

    npm install
  2. Start the development server

    npm run dev
  3. Open your browser Navigate to http://localhost:3000

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ layout.tsx          # Root layout with navigation
β”‚   β”œβ”€β”€ page.tsx            # Home page with overview
β”‚   β”œβ”€β”€ globals.css         # Global styles
β”‚   β”œβ”€β”€ csr/
β”‚   β”‚   └── page.tsx        # Client-Side Rendering demo
β”‚   β”œβ”€β”€ ssr/
β”‚   β”‚   └── page.tsx        # Server-Side Rendering demo
β”‚   β”œβ”€β”€ ssg/
β”‚   β”‚   └── page.tsx        # Static Site Generation demo
β”‚   └── isr/
β”‚       └── page.tsx        # Incremental Static Regeneration demo
└── components/
    └── Navigation.tsx      # Navigation component

πŸ” Key Implementation Details

CSR Implementation

'use client'
// Uses React hooks for client-side data fetching
// Shows loading states and error handling

SSR Implementation

// Server component with no-cache fetching
const response = await fetch(url, { cache: 'no-store' })

SSG Implementation

// Forces static generation at build time
export const dynamic = 'force-static'

ISR Implementation

// Revalidates every 60 seconds
const response = await fetch(url, { next: { revalidate: 60 } })

🎯 Learning Objectives

After exploring this demo, you'll understand:

  • When to use each rendering strategy
  • Performance implications of different approaches
  • SEO considerations for each method
  • Implementation patterns in Next.js 14
  • Trade-offs between loading speed and dynamic content

πŸ“Š Performance Comparison

Method Initial Load Navigation SEO Dynamic Content Server Load
CSR Slower Fast Poor Excellent Low
SSR Fast Slower Excellent Excellent High
SSG Fastest Fast Excellent None None
ISR Fast Fast Excellent Good Medium

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“œ License

This project is open source and available under the MIT License.

πŸ”— Additional Resources


🎯 Ready to Explore?

Experience all rendering strategies in action with real performance metrics!

If this demo helped you understand rendering strategies, please give it a star!

🀝 Contribute

Found an issue or have an improvement? Contributions are welcome!

πŸ“’ Share the Knowledge

Help other developers learn by sharing this resource:

  • Twitter/X: "Check out this comprehensive Next.js rendering demo: https://page-rendering-demo.vercel.app πŸš€ #NextJS #WebPerformance #ReactJS"
  • LinkedIn: "Great resource for understanding SSR, SSG, CSR, and ISR with real examples and performance metrics"

🏷️ Tags: nextjs react typescript rendering performance ssr ssg csr isr web-vitals education demo tutorial