MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Static (SSG) vs Dynamic (SSR) Rendering & generateStaticParams0%
Study Materials
Next.js 15Progress 0%
1.1Next.js 15 Overview & App Router vs Pages Router Architecture1.2Core File Conventions: page.tsx, layout.tsx, template.tsx & not-found.tsx1.3Dynamic Routes ([id]), Catch-All Routes ([...slug]) & Route Groups ((group))1.4Streaming UI with loading.tsx and Suspense Boundaries
2.1Server Components vs Client Components ("use client" boundary)2.2Data Fetching in Server Components & Async Server Logic2.3The Next.js 15 Caching System: Request Memoization & Data Cache2.4Static (SSG) vs Dynamic (SSR) Rendering & generateStaticParams
HomeTutorialsNext.js 15Static (SSG) vs Dynamic (SSR) Rendering & generateStaticParams
Server Actions ("use server"): Type-Safe Mutations Without API Endpoints

Static (SSG) vs Dynamic (SSR) Rendering & generateStaticParams

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Next.js automatically determines whether a route should be rendered statically at build time (Static Site Generation - SSG) or dynamically on every user request (Server-Side Rendering - SSR). For dynamic routes with parameters, generateStaticParams unlocks blazing static performance.


1. Static vs Dynamic Rendering

  • Static Rendering (Default): Routes are rendered into HTML at build time (npm run build) or during background revalidation. Resulting files are cached globally on edge CDNs for near-zero millisecond response times.
  • Dynamic Rendering: Routes are rendered on the server for each individual user request. Automatically triggered when using Dynamic Functions (cookies(), headers(), searchParams).

2. Dynamic Functions Triggering Dynamic Rendering

If a component uses information specific to an incoming user request, Next.js automatically opts that route into Dynamic Rendering:

  • cookies() from next/headers
  • headers() from next/headers
  • Accessing searchParams in page.tsx
1import { cookies } from 'next/headers';
2 
3export default async function UserCartPage() {
4 const cookieStore = await cookies();
5 const cartToken = cookieStore.get('cart_token'); // Dynamic function forces SSR!
6 
7 return <div>Your Cart Token: {cartToken?.value}</div>;
8}

3. Prerendering Dynamic Routes with generateStaticParams

For dynamic paths like app/courses/[slug]/page.tsx, Next.js doesn't know what slugs exist at build time unless you specify them. generateStaticParams queries your database during build time to generate static HTML pages for all known slugs!

1// app/courses/[slug]/page.tsx
2import { getAllCourseSlugs, getCourseBySlug } from '@/lib/courses';
3import { notFound } from 'next/navigation';
4 
5// 1. generateStaticParams: runs at build time on the server
6export async function generateStaticParams() {
7 const slugs = await getAllCourseSlugs(); // e.g. ['tailwind-css', 'nodejs-backend']
8 
9 return slugs.map((slug) => ({
10 slug: slug
11 }));
12}
13 
14// 2. Page Component: statically generated for all returned slugs!
15export default async function CourseDetailPage({
16 params
17}: {
18 params: Promise<{ slug: string }>;
19}) {
20 const { slug } = await params;
21 const course = await getCourseBySlug(slug);
22 
23 if (!course) notFound();
24 
25 return (
26 <div className="max-w-4xl mx-auto py-10">
27 <h1 className="text-4xl font-bold">{course.title}</h1>
28 <p className="mt-4 text-slate-600">{course.description}</p>
29 </div>
30 );
31}

4. The Dynamic Params Option (dynamicParams)

Control what happens when a user visits a dynamic slug that was NOT generated at build time:

1// true (default): Next.js will render the new slug dynamically on demand and cache it!
2// false: Next.js returns an immediate 404 for any slug not returned by generateStaticParams.
3export const dynamicParams = true;

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
What does the generateStaticParams function do in dynamic routes?
Question 2
What happens if a component uses cookies() or headers() from next/headers?
Question 3
What does setting export const dynamicParams = false; in a page do?
Question 4
What is the primary advantage of Static Site Generation (SSG) over Dynamic Server-Side Rendering (SSR)?
Question 5
Which symbol in the npm run build output indicates that a route has been statically pre-rendered?

Next Lesson

Server Actions ("use server"): Type-Safe Mutations Without API Endpoints

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
The Next.js 15 Caching System: Request Memoization & Data CacheServer Actions ("use server"): Type-Safe Mutations Without API Endpoints

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Next.js 15 with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext