Next.js
Overview
Next.js is a React framework (by Vercel) for building full-stack web applications. It layers file-system routing, server-side rendering, static generation, and React Server Components on top of React, plus built-in bundling, image optimization, and data-fetching primitives. Read this when scaffolding a Next.js app or reasoning about rendering modes, the App Router, or caching.
Official sources
Install / setup
npx create-next-app@latest
Core concepts
- App Router vs Pages Router. The App Router (
app/ directory) is the recommended model and uses React Server Components by default; the older Pages Router (pages/) remains supported.
- File-system routing. Routes are derived from the folder/file structure. In the App Router, special files such as
layout.tsx, page.tsx, loading.tsx, and error.tsx define UI and conventions per route segment.
- Server vs Client Components. Components render on the server by default; add the
"use client" directive to opt a component into client-side interactivity (state, effects, browser APIs).
- Rendering strategies. Pages can be statically rendered (SSG), dynamically rendered per request (SSR), or incrementally regenerated (ISR), giving per-route control over freshness vs performance.
- Root layout. The App Router requires a root
layout.tsx containing the <html> and <body> tags; it wraps all routes.
- Built-in optimizations. First-class
next/image, next/font, and a default bundler (Turbopack) ship out of the box; a public/ folder serves static assets from the base URL.
Best practices
- Prefer the App Router for new projects — it is the recommended setup that
create-next-app enables by default (per the official installation docs).
- Keep components as Server Components unless they need interactivity; only push
"use client" to the leaf components that actually need it, to minimize client JS.
- Use Module Path Aliases (
@/* via tsconfig.json paths/baseUrl) for clean imports — Next.js supports these natively.
- Use the appropriate package.json scripts (
next dev, next build, next start) for each stage; run linting through your own npm scripts (Next.js 16 no longer lints automatically during next build).
Common pitfalls
- Using browser-only APIs or React hooks in a Server Component → mark the component with
"use client" or move that logic into a dedicated client component.
- Forgetting the required root
layout.tsx with <html>/<body> → Next.js auto-creates one in dev, but production builds expect it; add it explicitly.
- Assuming
next build runs the linter (older behavior) → since Next.js 16 you must invoke the linter via your own npm script.
Examples
// app/page.tsx — a Server Component route at "/"
export default function Page() {
return <h1>Hello, Next.js!</h1>
}
Further reading
Related skills
- ../remix — React meta-framework built on web fundamentals
- ../gatsby — React static-site framework
- ../vite — build tool used by many React SPAs
1---2name: nextjs3description: React meta-framework for full-stack apps — file-system routing, Server Components, SSR/SSG/ISR; consult when building or debugging a Next.js app.4domain: stack5category: meta6tags: [react, ssr, rsc, app-router, vercel]7official_sources:8 - https://nextjs.org/docs9 - https://github.com/vercel/next.js10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/nextjs13---1415# Next.js1617## Overview18Next.js is a React framework (by Vercel) for building full-stack web applications. It layers file-system routing, server-side rendering, static generation, and React Server Components on top of React, plus built-in bundling, image optimization, and data-fetching primitives. Read this when scaffolding a Next.js app or reasoning about rendering modes, the App Router, or caching.1920## Official sources21- Docs: https://nextjs.org/docs22- Repo: https://github.com/vercel/next.js23- Install / getting started: https://nextjs.org/docs/app/getting-started/installation2425## Install / setup26```bash27npx create-next-app@latest28```2930## Core concepts31- **App Router vs Pages Router.** The App Router (`app/` directory) is the recommended model and uses React Server Components by default; the older Pages Router (`pages/`) remains supported.32- **File-system routing.** Routes are derived from the folder/file structure. In the App Router, special files such as `layout.tsx`, `page.tsx`, `loading.tsx`, and `error.tsx` define UI and conventions per route segment.33- **Server vs Client Components.** Components render on the server by default; add the `"use client"` directive to opt a component into client-side interactivity (state, effects, browser APIs).34- **Rendering strategies.** Pages can be statically rendered (SSG), dynamically rendered per request (SSR), or incrementally regenerated (ISR), giving per-route control over freshness vs performance.35- **Root layout.** The App Router requires a root `layout.tsx` containing the `<html>` and `<body>` tags; it wraps all routes.36- **Built-in optimizations.** First-class `next/image`, `next/font`, and a default bundler (Turbopack) ship out of the box; a `public/` folder serves static assets from the base URL.3738## Best practices39- Prefer the **App Router** for new projects — it is the recommended setup that `create-next-app` enables by default (per the official installation docs).40- Keep components as **Server Components** unless they need interactivity; only push `"use client"` to the leaf components that actually need it, to minimize client JS.41- Use **Module Path Aliases** (`@/*` via `tsconfig.json` `paths`/`baseUrl`) for clean imports — Next.js supports these natively.42- Use the appropriate **package.json scripts** (`next dev`, `next build`, `next start`) for each stage; run linting through your own npm scripts (Next.js 16 no longer lints automatically during `next build`).4344## Common pitfalls45- Using browser-only APIs or React hooks in a Server Component → mark the component with `"use client"` or move that logic into a dedicated client component.46- Forgetting the required root `layout.tsx` with `<html>`/`<body>` → Next.js auto-creates one in dev, but production builds expect it; add it explicitly.47- Assuming `next build` runs the linter (older behavior) → since Next.js 16 you must invoke the linter via your own npm script.4849## Examples50```tsx51// app/page.tsx — a Server Component route at "/"52export default function Page() {53 return <h1>Hello, Next.js!</h1>54}55```5657## Further reading58- App Router getting started: https://nextjs.org/docs/app/getting-started59- create-next-app reference: https://nextjs.org/docs/app/api-reference/cli/create-next-app6061## Related skills62- ../remix — React meta-framework built on web fundamentals63- ../gatsby — React static-site framework64- ../vite — build tool used by many React SPAs