Lesson 77/100

Tutorials React.js Tutorial

SSG — Complete Guide

SSG — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of React.js Tutorial on Toolliyo Academy.

On this page

React.js Tutorial · Lesson 77 of 100

ISR

Beginner ✓Intermediate ✓Advanced ✓Professional

Professional · 4 — Real projects · ~25 min read · Module 8: Real-Time & Full-Stack React

Introduction

Professional project lesson: ISR. You will put together routing, data, and UI like a portfolio app. Build one piece at a time — do not rush. Incremental Static Regeneration updates static pages after deploy without rebuilding the whole site. Next.js revalidates a page on a timer or on demand. Product catalog with 10,000 SKUs — rebuild all nightly is slow; ISR refreshes each page when stale.

Frontend and backend are separate programs that talk over HTTP. React is the frontend; your API is the backend.

When will you use this?

Use when your React app must talk to a real backend or show live updates.

  • React frontends talk to .NET, Node, or Java APIs — fetch and auth are daily tasks.
  • Live chat and stock tickers use WebSockets or SignalR with React state.

Real-world: hourly product stock refresh

Amazon product page static but revalidates every hour — stock count updates without rebuilding entire site.

Production-style code

// Next.js ISR
export const revalidate = 3600; // seconds

export default async function ProductPage({ params }) {
  const product = await fetchProduct(params.id);
  return (
    <div>
      <h1>{product.name}</h1>
      <p>In stock: {product.stock}</p>
    </div>
  );
}

What happens in production: ISR blends SSG speed with fresher data — ideal for catalog pages with moderate update frequency.

Lesson example (start here)

Copy this smaller example first. Once it works, compare it with the real-world code above.

export const revalidate = 3600; // seconds

export default async function ProductPage({ params }) {
  const product = await fetchProduct(params.id);
  return <ProductView product={product} />;
}

Line-by-line walkthrough

CodeWhat it means
export const revalidate = 3600; // secondsMakes this function or variable available to other files that import it.
export default async function ProductPage({ params }) {Makes this function or variable available to other files that import it.
const product = await fetchProduct(params.id);Part of the ISR example — read it together with the lines before and after.
return <ProductView product={product} />;Sends UI or a value back to whoever called this function.
}Closes a block started by { or ( above.

How it works (big picture)

  • First request after stale period triggers background rebuild.
  • Users still get cached page instantly; next visitor gets fresh HTML.

Do this on your computer

  1. Add revalidate export to Next.js page.
  2. Set interval based on how fresh data must be.
  3. Use on-demand revalidate API for urgent updates.
  4. Read the real-world section and name which part of the app uses this topic.
  5. Run the example locally and confirm the same behavior in the browser.
  6. Change one value in the example (text, initial state, or URL) and predict what will happen before you save.

Experiments — try changing this

  • Change text or labels in the example and save — watch the browser update.
  • Break the code on purpose (remove a bracket), read the error message, then fix it.

Remember

ISR = static speed + periodic refresh. revalidate in seconds. Next.js feature.

Common questions

ISR vs client fetch?

ISR gives SEO-friendly HTML; client fetch hides content from crawlers without SSR.

How long should I spend on ISR?

Until you can explain it in your own words and run the example without looking at the answer. Beginners often need 30–60 minutes per new hook or routing topic; setup lessons may take one afternoon.

What if I get stuck on ISR?

Re-read the line-by-line walkthrough, check the browser console for red errors, and compare your code character-by-character with the example. Search the exact error text — someone else had it too.

Where is ISR used in real jobs?

See the real-world section above — the same pattern appears in LMS, banking, e-commerce, and SaaS products. Interviewers ask you to explain it using one concrete example from your project or this lesson.

Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

React.js Tutorial
Course syllabus

React.js Tutorial

Module 1: React Basics & Setup
Module 2: Props, Events & Lists
Module 3: Forms & Hooks
Module 4: Routing & Data
Module 5: State & Authentication
Module 6: Architecture & React 19
Module 7: Performance
Module 8: Full-Stack & Real-Time
Module 9: Testing & Deployment
Module 10: ShopCart Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details