What is Next.js? A Complete Beginner's Guide
React changed the way developers build user interfaces by introducing components, but React by itself is only a library for building UI — it does not decide how your app is routed, how pages are rendered, or how your site performs in search engines. Teams building real production React apps had to bolt on routers, bundlers, server rendering setups, and SEO tooling by hand, and every team did it differently.
Next.js was created to solve exactly this problem. It is a React framework, built by Vercel, that wraps React with sensible defaults for routing, rendering, data fetching, image optimization, and deployment. Instead of assembling a dozen tools yourself, Next.js gives you a production-ready structure out of the box.
The biggest reason companies choose Next.js over plain React is rendering strategy. Plain React apps typically render entirely in the browser, which can hurt SEO and initial load speed. Next.js lets you choose, per page, whether content is rendered on the server, pre-built at compile time, or rendered in the browser — giving you the best of all worlds depending on what each page needs.
Learning Objectives
- Define what Next.js is and explain its relationship to React.
- Identify the core problems Next.js solves that plain React does not.
- Distinguish between Server-Side Rendering (SSR), Client-Side Rendering (CSR), and Static Site Generation (SSG).
- Understand why rendering strategy affects SEO and performance.
- Recognize real-world companies and use cases that rely on Next.js.
Core Definitions
- Next.js: A React framework that adds routing, server rendering, static site generation, image optimization, and other production features on top of React.
- React: A JavaScript library for building user interfaces out of reusable components; React alone has no built-in routing or rendering strategy.
- CSR (Client-Side Rendering): A rendering approach where the browser downloads a mostly empty HTML page and JavaScript, then builds the UI in the browser.
- SSR (Server-Side Rendering): A rendering approach where the server generates full HTML for a page on every request and sends it to the browser already populated.
- SSG (Static Site Generation): A rendering approach where HTML pages are pre-built once at build time and served as static files for every visitor.
- Hydration: The process where React attaches event listeners and interactivity to server-rendered HTML once it reaches the browser.
- Framework: A structured set of tools and conventions built around a library (like React) that provides opinionated solutions for common application needs.
Detailed Explanation
Think of React as a box of building blocks — buttons, cards, forms — but no instructions for how to arrange them into a full house with plumbing and electricity. Next.js is the pre-designed house blueprint: it tells you where the rooms (pages) go, how water (data) flows in, and how the house looks the moment someone opens the door (initial render).
With plain React (via Create React App, for example), the browser downloads a nearly blank HTML file plus a JavaScript bundle. Only after that JavaScript runs does the page fill with content. This is Client-Side Rendering. It works, but search engine crawlers and users on slow connections see a blank page for a moment, and search engines historically struggled to index content that only appears after JavaScript executes.
Next.js solves this by offering Server-Side Rendering: the server builds the full HTML for a page every time it's requested, so the browser receives a complete, readable page instantly, and JavaScript then 'hydrates' it to make it interactive. For pages that don't change often, like a blog post or marketing page, Next.js offers Static Site Generation: the HTML is built once during deployment and served instantly to every visitor from a CDN, making it extremely fast.
The real power of Next.js is that you are not locked into one strategy. A product listing page might use SSG because prices update once a day. A user dashboard might use SSR or CSR because the data is personal and changes constantly. Next.js lets each page choose its own rendering strategy.
Diagram Description
Visualize three side-by-side pipelines showing how a browser gets a page:
CSR:
[Browser requests page] --> [Server sends near-empty HTML + JS bundle] --> [Browser runs JS] --> [Page renders content]
SSR:
[Browser requests page] --> [Server builds full HTML on the fly] --> [Browser shows complete page instantly] --> [JS hydrates for interactivity]
SSG:
[Build time: HTML pre-generated once] --> [Browser requests page] --> [CDN serves pre-built HTML instantly] --> [JS hydrates for interactivity]
Comparison Table
| Aspect | CSR | SSR | SSG |
|---|---|---|---|
| When HTML is built | In the browser, after JS loads | On the server, per request | Once, at build/deploy time |
| Initial load speed | Slower (blank page first) | Fast (full HTML immediately) | Fastest (served from CDN) |
| SEO friendliness | Weaker unless carefully handled | Strong | Strong |
| Best for | Highly interactive dashboards | Frequently changing, personalized pages | Blogs, marketing pages, docs |
| Next.js approach | Client Components | Server Components / dynamic rendering | generateStaticParams / static rendering |
Next.js Practical Example
// A minimal Next.js page (App Router) — app/page.tsx
export default function HomePage() {
return (
<main>
<h1>Welcome to My Next.js Site</h1>
<p>This page is rendered on the server by default.</p>
</main>
);
}
// Fetching data on the server (Server Component) — app/products/page.tsx
async function getProducts() {
const res = await fetch('https://api.example.com/products', {
next: { revalidate: 3600 }, // regenerate this page every hour (ISR)
});
return res.json();
}
export default async function ProductsPage() {
const products = await getProducts();
return (
<ul>
{products.map((p) => (
<li key={p.id}>{p.name} — ₹{p.price}</li>
))}
</ul>
);
}
The HomePage component is a Server Component by default in Next.js's App Router — it renders to HTML on the server before it ever reaches the browser, giving fast, SEO-friendly output with zero extra configuration. The ProductsPage example goes a step further: it fetches data directly inside the component on the server using async/await, and the `revalidate: 3600` option tells Next.js to treat this as Incremental Static Regeneration — the page behaves like SSG but automatically refreshes every hour, blending the speed of static pages with reasonably fresh data.
Industry Examples
- Netflix's marketing and jobs pages use Next.js's static and server-rendering capabilities to ensure fast load times and strong SEO for a global audience.
- TikTok's web version uses Next.js to serve fast, indexable pages while still supporting rich, interactive video feeds.
- Hulu and Twitch use Next.js for parts of their platforms where fast initial loads and SEO matter, such as show or channel landing pages.
- Notion's public-facing marketing site is built with Next.js, combining static pages for speed with dynamic sections for personalization.
- Startups building SaaS dashboards frequently choose Next.js so marketing pages can be statically generated for SEO while the app dashboard itself uses client-side rendering for interactivity.
Interview Questions and Answers
Q1. What is Next.js and how is it different from React?
React is a JavaScript library for building UI components; it has no built-in routing, rendering strategy, or bundling setup. Next.js is a framework built on top of React that adds file-based routing, multiple rendering strategies (SSR, SSG, CSR), image optimization, and a production-ready build system, so developers don't have to assemble these pieces manually.
Q2. What is the difference between SSR and SSG?
SSR generates the HTML for a page on the server for every single request, which is useful for frequently changing or personalized content. SSG generates the HTML once at build time and serves the same static file to every visitor, which is faster and cheaper but suited to content that doesn't change on every request.
Q3. Why is CSR sometimes bad for SEO?
In pure CSR, the server sends a nearly empty HTML shell, and content only appears after JavaScript executes in the browser. Some search engine crawlers and social media link-preview bots may not fully execute JavaScript or may time out before content renders, leading to poor indexing of the actual page content.
Q4. What is hydration in the context of Next.js?
Hydration is the process where React takes server-rendered static HTML already in the browser and attaches event listeners and internal state to it, turning static markup into a fully interactive React application without re-rendering the visible content from scratch.
Q5. Can a single Next.js app use SSR, SSG, and CSR at the same time?
Yes. Next.js allows rendering strategy to be chosen per route or component. A marketing page can be statically generated, a dashboard page can be server-rendered per request, and a specific interactive widget within a page can be a Client Component rendered in the browser.
MCQs With Answers
1. Next.js is best described as:
- A CSS framework
- A React framework for production apps
- A database
- A testing library
Answer: B. A React framework for production apps
Explanation: Next.js is built on top of React and adds routing, rendering strategies, and production tooling that plain React does not provide.
2. Which rendering strategy builds HTML once at deploy time and reuses it for every visitor?
- CSR
- SSR
- SSG
- Hydration
Answer: C. SSG
Explanation: Static Site Generation pre-builds pages during the build process, so the same HTML file is served to all visitors until the next deploy or revalidation.
3. What problem does SSR primarily solve compared to CSR?
- Reduces bundle size to zero
- Sends fully rendered HTML immediately, improving initial load and SEO
- Eliminates the need for a server
- Removes the need for JavaScript entirely
Answer: B. Sends fully rendered HTML immediately, improving initial load and SEO
Explanation: SSR builds complete HTML on the server per request, so the browser gets readable content immediately instead of waiting for client-side JavaScript to render it.
4. Hydration in Next.js refers to:
- Compressing images
- Attaching interactivity to already-rendered HTML
- Minifying CSS
- Creating a new database connection
Answer: B. Attaching interactivity to already-rendered HTML
Explanation: Hydration lets React reuse server-rendered markup and add event listeners/state, avoiding a full re-render while making the page interactive.
5. Which is a realistic use case for SSG?
- A live stock trading dashboard
- A blog post that rarely changes
- A real-time chat application
- A user's private account settings page
Answer: B. A blog post that rarely changes
Explanation: SSG suits content that is the same for every visitor and doesn't change often, like blog posts or marketing pages, since the page is pre-built once.
Common Mistakes to Avoid
- Assuming Next.js replaces React entirely — it builds on top of React, and React knowledge is still required.
- Thinking every page must use the same rendering strategy across an app; Next.js supports mixing strategies per route.
- Believing SSR is always better than SSG; SSR adds server load on every request, while SSG is cheaper and faster for unchanging content.
- Confusing hydration with rendering; hydration only adds interactivity, it does not re-render visible content from scratch.
- Overlooking that CSR is still useful for highly interactive, non-SEO-critical sections like dashboards.
Interview Notes
- Next.js = React + routing + rendering strategies + production tooling.
- CSR renders in the browser after JS loads; SSR renders on the server per request; SSG renders once at build time.
- SEO and initial load speed are the primary reasons teams choose SSR/SSG over pure CSR.
- Hydration is the step where static server-rendered HTML becomes interactive React in the browser.
- Next.js allows per-page/per-route selection of rendering strategy within the same application.
Key Takeaways
- Next.js exists to remove the routing, rendering, and tooling decisions developers previously had to make manually with plain React.
- Choosing the right rendering strategy per page — SSR, SSG, or CSR — directly impacts SEO and perceived performance.
- Real-world companies mix rendering strategies within a single Next.js application depending on each page's needs.
- Understanding rendering strategy is the conceptual foundation for every later Next.js topic, from routing to data fetching.
Summary
Next.js is a React framework that adds the missing pieces plain React doesn't provide: file-based routing, multiple rendering strategies, image optimization, and production-ready tooling. The core concept every beginner must grasp is rendering strategy — CSR renders in the browser after JavaScript loads, SSR renders full HTML on the server for every request, and SSG pre-builds HTML once at build time. Each strategy trades off speed, freshness, and SEO differently, and Next.js's biggest advantage is letting developers choose the right strategy per page rather than forcing one approach across an entire application.