Next.js

React, but it handles the boring 80%.

▶ the lesson · narrated sketch video · tap for sound

the intro

Next.js is a framework on top of React that adds routing, server rendering, data fetching, and deployment conventions. Components render on the server by default, pages are folders, and APIs live next to your pages. It removes most of the setup work a real React app needs.

the sample

a page is just a folder

app/
  page.tsx        → /
  about/page.tsx  → /about
  users/[id]/
    page.tsx      → /users/:id

fun fact ✦

Next.js popularized “file-based routing” — your folder tree literally becomes your sitemap.

the docs

the deep dive

the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid

React answers one question: how do I render this UI? A real app asks five more — routing, data fetching, server rendering, SEO tags, deployments. Next.js answers those with conventions instead of config: the file system is the router, components render on the server by default, and the boring 80 percent is already done.

conventions instead of config

requestserver renderinteractive
a request in Next.js: HTML first, hydration second

key terms

server component

Renders on the server and ships zero JavaScript for it. The default in the app router.

async function Page()

"use client"

A marker that flips a file back to browser-land: state, effects, and event handlers live there.

"use client" at the top

file router

Folders inside app become URLs. No route config file, no imports to register.

app/about/page.tsx

ISR

Incremental static regeneration: a static page that quietly rebuilds every N seconds.

revalidate: 60

how it works

  1. 1
    Create the folder

    app/about/page.tsx is now the /about route, server-rendered by default. That is the whole tutorial.

  2. 2
    Fetch during render

    Components can be async: await your data right in the component body. No useEffect, no loading-spinner choreography.

  3. 3
    Mark the interactive bits

    Buttons with onClick need "use client". Everything else stays on the server and ships no JS.

  4. 4
    Add the polish

    export const metadata for titles and social cards; a loading.tsx file becomes an instant skeleton.

the code, explained

a dynamic route, data included

1// app/users/[id]/page.tsx
folder = URL: this file renders /users/anything
2export default async function Page({
server components can await directly
3 params,
4}: { params: Promise<{ id: string }> }) {
5 const { id } = await params
dynamic params arrive as a Promise in Next 15+
6 const user = await getUser(id)
7 return <Profile user={user} />
8}

side by side

server comp

  • renders once on the server
  • ships zero JS for itself
  • can read databases directly
  • no state, no handlers
VS

client comp

  • interactive: state and events
  • code ships to the browser
  • hooks and effects allowed
  • opt in with "use client"
🪤 gotcha

Props crossing into a "use client" component must be serializable: numbers, strings, plain objects. A function or a class instance passed from a server component will throw at runtime. Pass data and ids down; pass behavior up via server actions.

quick answers

Is Next.js free?

The framework is MIT-licensed and self-hosts anywhere. Vercel, which makes it, sells hosting — but hosting is optional, not required.

Do I still write React normally?

Components and hooks are unchanged. The new rules: server by default, "use client" where interactive, folders as routes.

When should I not use it?

A single static page, or an app entirely behind a login with no SEO needs. Plain React with Vite is lighter for those.

quick hits about Next.js

short answers · interviews, tips, trivia & hidden gems

🎤 interview

SSR, SSG, ISR?watch ↗

🎤 interview

What is use client?watch ↗

🎤 interview

Do you always need Next.js?watch ↗

📚 tutorial

How does routing work?watch ↗

🔧 useful

SEO in React is painful?watch ↗

🆕 update

API routes for forms?watch ↗

💎 deep

Instant loading states?watch ↗

💎 deep

Need an API endpoint?watch ↗