Introduction to Next.js

Understand what Next.js is, why it exists, and how senior engineers position it in a real enterprise tech stack.

Last reviewed: January 2025

·Next.js 13Next.js 14Next.js 15
✅
Quick Understanding: Next.js is a React framework that adds server-side rendering, file-based routing, API routes, and production optimisations on top of React. If React is the engine, Next.js is the fully assembled car — ready to drive into production.

🔍 What Is It?

Next.js is an open-source full-stack React framework built and maintained by Vercel. It extends React with:

  • →File-based routing — your folder structure becomes your URL structure
  • →Server-side rendering (SSR) — HTML generated on the server per request
  • →Static site generation (SSG) — HTML pre-built at deploy time
  • →Incremental static regeneration (ISR) — static pages that refresh in the background
  • →API Routes / Route Handlers — backend endpoints inside the same project
  • →Built-in optimisations — image compression, font loading, script management
  • →App Router — React Server Components, streaming, nested layouts (Next.js 13+)

Next.js is the most widely deployed React framework in enterprise. It solves the problems that plain React leaves unsolved: routing, server rendering, data fetching, and production build optimisation.

🎯 Why Do We Need It?

Plain React is a UI library — it renders components in the browser. That leaves you responsible for:

  • →Setting up a router (React Router, TanStack Router)
  • →Configuring Webpack / Vite from scratch
  • →Solving SEO (React apps ship empty HTML shells — search engines struggle)
  • →Building a backend separately (Express, Fastify)
  • →Optimising images, fonts, and third-party scripts manually
  • →Handling server rendering yourself

Next.js solves every one of these out of the box. It lets a small team ship a production-grade, SEO-friendly, performant full-stack application without a separate backend service.

🏗️ What Happens in Real Projects?

Next.js powers some of the world's largest sites:

  • →Vercel (obviously), TikTok, Twitch, GitHub Copilot dashboard
  • →Enterprise SaaS dashboards, e-commerce storefronts, marketing sites, internal tools

Typical enterprise use cases:

  • →Marketing site with CMS integration (Contentful, Sanity) — SSG + ISR
  • →Customer portal with auth — SSR + Route Handlers
  • →E-commerce storefront — SSG for product pages, SSR for cart/checkout
  • →Internal analytics dashboard — CSR with Server Components for initial data

In a real project, Next.js replaces:

  • →React + React Router + Express + separate SSR setup
  • →Manual Webpack configuration
  • →Separate image CDN setup
  • →Manual meta tag management

⚙️ How It Works

The Next.js request lifecycle (App Router):

  1. Request hits the server (or CDN edge)
  2. Next.js matches the URL to a route segment in the app/ directory
  3. Server Components run on the server — fetch data, render HTML
  4. The HTML stream is sent to the browser progressively (streaming)
  5. Client Components hydrate in the browser — React takes over interactivity
  6. Subsequent navigations use client-side routing — no full page reload

Build pipeline:

  • →next build compiles TypeScript, bundles JS, pre-renders static pages
  • →next start runs the Node.js production server
  • →On Vercel, static assets go to CDN, server functions become serverless functions

💻 Example

A Minimal Next.js 14 App — The smallest meaningful Next.js app — a page that fetches data on the server and renders it.

tsx
// This runs on the SERVER — no useEffect, no loading state needed
export default async function HomePage() {
  // Direct async/await in a component — only possible in Server Components
  const res = await fetch('https://api.example.com/products', {
    next: { revalidate: 3600 }, // ISR: refresh every hour
  });
  const products = await res.json();

  return (
    <main>
      <h1>Products ({products.length})</h1>
      <ul>
        {products.map((p: { id: string; name: string }) => (
          <li key={p.id}>{p.name}</li>
        ))}
      </ul>
    </main>
  );
}

🤔 Common Confusions

❓ Is Next.js replacing React or competing with it?

Neither. Next.js is built on top of React — it uses React internally. Every Next.js component is a React component. Next.js adds the framework layer (routing, SSR, build tooling) that React deliberately leaves out.

❓ Do I need a Node.js server to run Next.js?

Only for SSR and Route Handlers. Fully static Next.js apps (SSG only) can be exported as plain HTML/CSS/JS and hosted anywhere — S3, GitHub Pages, Netlify. But most real apps use at least some server features.

❓ Is Next.js only for Vercel?

No. Next.js is open source and runs on any Node.js host — AWS Lambda, Google Cloud Run, Railway, Render, self-hosted VMs. Vercel just provides the best zero-config deployment experience for it.

🚨 Common Production Issues

Cold start latency on serverless deployments — SSR functions that haven't been called recently take 200–800ms to initialise. Mitigate with edge runtime or pre-warming.

Bundle size bloat — importing large libraries (moment.js, lodash) in Server Components is fine (never sent to browser), but the same import in a Client Component inflates the JS bundle.

Caching confusion — Next.js 14 has aggressive default caching. Forgetting to set cache: "no-store" on sensitive data endpoints causes stale data bugs that are hard to reproduce locally.

✅ Best Practices

Start with Server Components by default — opt into Client Components only when you need interactivity, browser APIs, or event handlers

Use the App Router (app/) for all new projects — Pages Router (pages/) is legacy

Co-locate route-specific components inside the route folder — only shared components go in components/

Use next/image for all images — it handles WebP conversion, lazy loading, and CLS prevention automatically

Set explicit cache policies on every fetch call — never rely on defaults in production

🏛️ Architect's Note

Senior Architect's Perspective

Next.js is a framework decision that ages well. The App Router's Server Component model aligns perfectly with how enterprise backends think — data lives on the server, only the minimum needed for interactivity goes to the client. This reduces bundle size, improves SEO, and simplifies data fetching dramatically.

The one architectural risk: vendor alignment with Vercel. Some Next.js features (ISR, Edge Middleware, Image Optimisation) work best or exclusively on Vercel infrastructure. If your organisation has a mandate to use AWS or Azure, evaluate carefully and consider whether the Pages Router (more portable) or a different framework (Remix, Astro) is a better fit.

💬 Frequently Asked Questions

Should I use the App Router or Pages Router for a new project?

App Router for all new projects. Pages Router is stable and will be maintained, but all new Next.js features (Server Components, streaming, Server Actions) are App Router only. The learning curve is steeper but the architecture is significantly better.

What is the difference between Next.js 13 and Next.js 14?

Next.js 13 introduced the App Router as beta. Next.js 14 stabilised it, deprecated the Turbopack beta label, and introduced stable Server Actions. Next.js 15 added React 19 support and changed fetch caching defaults to no-store. Always check the migration guide when upgrading.

Can I use Next.js for a REST API backend only?

Technically yes via Route Handlers, but it is not the right tool. Next.js is optimised for full-stack apps where the frontend and backend are tightly coupled. For a standalone REST API, use Express, Fastify, or NestJS.

🎯 Key Takeaways

1Next.js is a full-stack React framework — it adds routing, SSR, API routes, and optimisations on top of React
2Use the App Router (app/ directory) for all new Next.js 13+ projects
3Server Components run on the server — no JS sent to browser, direct database/API access
4Next.js replaces the need for a separate Express backend in most full-stack React apps
5Aggressive caching is a feature — but must be explicitly configured to avoid stale data bugs
6Not Vercel-only — but Vercel gives the best zero-config deployment experience

🎯 Practice this topic in interviews

↗ Where this topic fits

Sources

Sources / References

Use these Next.js references to verify the concept in official docs and continue into the most relevant SplashRide pages.

Related SplashRide pages

SplashRide Next.js learning path

Browse the full Next.js topic collection and learning order on SplashRide.

Next.js Interview Prep

Practice Next.js interview questions and scenario-based answers.

Frontend Engineer Career Path

A beginner-friendly journey through web foundations, React, production frontend engineering, and interview preparation.

Full Stack Java Developer Career Path

A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.

Project Structure

Master the Next.js App Router project structure — folders, conventions, and how senior engineers organise large-scale Next.js applications.

Next.js App Router Explained: Server Components, Layouts, and Routing

Learn the Next.js App Router with Server Components, nested layouts, streaming, Route Handlers, data fetching, and Pages Router migration guidance.