KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
▲

Next.js

Topic Hub & Articles

Next.js Intro

10 min

Next.js Installation

10 min

Next.js Routing

10 min

Next.js Pages

10 min

Next.js App Router

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Layouts

10 min

Next.js Linking and Navigating

10 min

Next.js Loading UI and Streaming

10 min

Next.js Error Handling

10 min

Next.js Data Fetching

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Server Actions

10 min

Next.js Rendering

10 min

Next.js CSS Modules

10 min

Next.js Image Optimization

10 min

Next.js Font Optimization

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Script Optimization

10 min

Next.js Static File Serving

10 min

Next.js Metadata

10 min

Next.js API Routes

10 min

Next.js Middleware

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Authentication

10 min

Next.js Deployment

10 min

Next.js Internationalization

10 min

Next.js Security

10 min

Next.js Performance

10 min

Recap Quiz

Gated

Milestone Assessment

Progress
0%

0 / 25 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
Next.jsNext.js Tutorial
Lesson

Next.js Rendering

10 min reading
Free Course

Next.js Rendering: Static, Dynamic, and ISR Strategies

Next.js rendering decides whether a route's HTML is built once ahead of time or generated fresh on each user request. The App Router picks static or dynamic rendering automatically based on the APIs each route reads.

Choosing the right strategy balances speed and freshness. Static pages serve straight from a CDN in milliseconds, while dynamic pages always reflect live user state.

flowchart LR
    A["Route Evaluation"] --> B{"Uses cookies(), headers(), or no-store?"}
    B -- "No" --> C["Static Rendering (Build Time)"]
    B -- "Yes" --> D["Dynamic Rendering (Request Time)"]
    C --> E{"revalidate = N set?"}
    E -- "Yes" --> F["ISR Background Refresh"]

Comparing the Three Rendering Modes

Strategy When HTML Builds Best Fit
Static Rendering (SSG) During npm run build Docs, marketing pages, landing views
Dynamic Rendering (SSR) On every HTTP request User dashboards, carts, private feeds
Incremental Static Regeneration (ISR) Built statically, refreshed on interval Product catalogs, blogs, news listings

Static Rendering by Default

Routes that do not read request-specific data build once during deployment and cache globally.

// app/about/page.tsx - Static Rendering
export default function AboutPage() {
  return (
    <section className="p-6">
      <h2 className="text-2xl font-bold">About Our Platform</h2>
      <p className="mt-2 text-gray-600">
        This page compiles into static HTML at build time for instant delivery.
      </p>
    </section>
  );
}

Dynamic Rendering at Request Time

Reading cookies(), headers(), searchParams, or calling fetch() with { cache: 'no-store' } switches that route to dynamic rendering automatically.

// app/account/page.tsx - Dynamic Rendering
import { cookies } from 'next/headers';

export default async function AccountPage() {
  const cookieStore = await cookies();
  const theme = cookieStore.get('theme')?.value ?? 'light';

  return (
    <section className="p-6">
      <h2 className="text-2xl font-bold">Account Settings</h2>
      <p className="mt-2">Active theme preference: {theme}</p>
    </section>
  );
}

Incremental Static Regeneration (ISR)

Export revalidate from a route file to serve cached static HTML while refreshing stale content in the background after a fixed number of seconds.

// app/articles/[slug]/page.tsx - ISR
export const revalidate = 60;

export default async function ArticlePage({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;
  const res = await fetch(`https://api.example.com/articles/${slug}`, {
    cache: 'force-cache',
  });
  const article = await res.json();

  return (
    <article className="p-6">
      <h2 className="text-2xl font-bold">{article.title}</h2>
      <p className="mt-3">{article.summary}</p>
    </article>
  );
}

Common Mistakes

  • Reading cookies() inside the root layout.tsx: That forces every route underneath the root layout into dynamic rendering.
  • Using revalidate = 0 everywhere: Setting zero revalidation turns off static caching across routes that rarely change and increases server load.
  • Forgetting generateStaticParams for static dynamic routes: Without generateStaticParams, dynamic [slug] pages render on first visit instead of at build time.

Frequently Asked Questions

What is Partial Prerendering (PPR) in Next.js?

Partial Prerendering serves a static HTML shell immediately while streaming dynamic <Suspense> holes on the same HTTP response.

How do I force a route to stay static during build?

Export export const dynamic = 'force-static'; inside the route file, though avoid reading cookies() or headers() in that segment.

Does npm run dev show static vs dynamic caching accurately?

No, development mode re-renders routes on every refresh; always test caching behavior with npm run build followed by npm run start.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

Next.js Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format HTML markup
CSS Formatter
Clean and format stylesheets
All Next.js Articles
Deep-dive guides, tips & discussions
PreviousNext.js Server Actions
Continue JourneyNext: Next.js CSS Modules

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum