Skip to content
Tutorials Center
My learning

Topics

Next.js Tutorial

Learn Next.js step by step: 72 lessons in 12 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Next.js? Learn what Next.js adds to React: routing, server rendering, data fetching, optimization and deployment, plus App Router versus Pages Router explained.
  2. 2 Creating a Next.js App Create a Next.js project with create-next-app, understand each prompt (TypeScript, Tailwind, src folder), and learn the dev, build and start scripts.
  3. 3 Project Structure A tour of a Next.js project: the app folder, public, config files, special file names, colocation, private folders, route groups and the src directory.
  4. 4 How a Request Flows Through Next.js Follow a request through Next.js from build time to the browser: route matching, Server Components, the RSC payload, HTML streaming and hydration.

Routing

  1. 5 Pages and Layouts Create pages with page.tsx and shared UI with layout.tsx, write the required root layout, nest layouts and see why they keep their state between pages.
  2. 6 File-Based Routing Learn how Next.js maps folders and page.tsx files to URLs, how nested routes work, what conflicts to avoid and how a URL is matched to a folder.
  3. 7 Dynamic Routes Turn a folder name like [slug] into a route that matches many URLs. Learn how params arrive as a promise, how to type them, and how generateStaticParams fits in.
  4. 8 Catch-All and Optional Catch-All Routes Match URLs of any depth with [...slug] and [[...slug]]. See how params become arrays, which route wins when several match, and which layouts are invalid.
  5. 9 Route Groups and Private Folders Organize an App Router project without changing URLs: use (group) folders for shared layouts and multiple root layouts, and _private folders to keep files out of routing.
  6. 10 Linking and Navigation Navigate in the App Router: the Link component, prefetching, useRouter and usePathname, active links, redirect on the server, and how scrolling behaves.
  7. 11 Search Params and Navigation Hooks Read the query string on the server with the searchParams prop and in the browser with useSearchParams, then build a shareable filter UI with the navigation hooks.
  8. 12 Parallel and Intercepting Routes Render several pages in one layout with @slot folders, add default.tsx fallbacks, and build URL-driven modals with intercepting routes. Soft vs hard navigation explained.
  9. 13 loading.tsx, error.tsx and not-found.tsx Handle slow, broken and missing pages in the Next.js App Router: loading UI, error boundaries with reset, notFound(), global-error and per-segment fallbacks.
  10. 14 Templates and Other Special Files Learn the rest of the App Router file conventions: template.tsx versus layout, default.tsx, route.ts, favicon and icon files, Open Graph images, robots and sitemap.

Server and Client Components

  1. 15 React Server Components Learn what React Server Components are, how async components fetch data directly, why they ship zero client JavaScript, and what they can and cannot do in Next.js.
  2. 16 Client Components and "use client" Learn what the use client directive does in Next.js: where the server-client boundary sits, when you need Client Components, how they hydrate and how they affect bundle size.
  3. 17 Composing Server and Client Components Mix Server and Client Components well: push the boundary down, pass Server Components as children, follow the props serialization rules and use interleaving patterns.
  4. 18 Keeping Server Code on the Server Stop secrets and server logic from reaching the browser in Next.js: the server-only and client-only packages, NEXT_PUBLIC_ variables, taint APIs and context providers.
  5. 19 Inside the RSC Payload Look inside the React Server Components payload: how Next.js serializes the tree, marks client component references, streams rows and merges updates on navigation.

Data Fetching and Caching

  1. 20 Fetching Data in Server Components Fetch data in Next.js Server Components with async/await, fetch and direct database calls, avoid request waterfalls with Promise.all, and learn request memoization.
  2. 21 Fetching Data on the Client Learn when to fetch data in the browser in Next.js, how to stream a promise from a Server Component into use(), and when SWR or TanStack Query is worth adding.
  3. 22 Caching in Next.js: the Big Picture Understand every caching layer in the Next.js App Router: request memoization, the data cache, the full route cache and the router cache, and what changed in 15 and 16.
  4. 23 The use cache Directive and Cache Components Learn the use cache directive in Next.js 16: caching functions and components, cache keys, cacheLife and cacheTag, and static shells with dynamic holes.
  5. 24 Revalidating Data Keep cached Next.js data fresh: time-based revalidation, on-demand revalidatePath and revalidateTag, updateTag for read-your-writes and stale-while-revalidate.
  6. 25 Static vs Dynamic Rendering Learn what makes a Next.js route static or dynamic: cookies, headers, searchParams, connection(), force-dynamic, and how to read the build output symbols.
  7. 26 Data Access Layers and ORMs Organize database code in Next.js with a data access layer: Prisma and Drizzle queries, DTOs that hide secrets, React cache deduplication and no waterfalls.
  8. 27 Databases in Next.js - MongoDB, Prisma and Drizzle Connect a Next.js app to MongoDB, Prisma or Drizzle. Reuse one connection in development, query from Server Components and Route Handlers, and keep secrets on the server.

Rendering Strategies

  1. 28 SSG, SSR, ISR and Streaming Compared Compare static generation, server rendering, incremental static regeneration and streaming in Next.js: when each fits, the tradeoffs and a decision table.
  2. 29 Static Generation and generateStaticParams Build pages ahead of time in Next.js: generateStaticParams, dynamicParams, nested params, and the static export option with its limits, plus live stand-ins.
  3. 30 Draft Mode and Headless CMS Previews Use Next.js Draft Mode to preview unpublished CMS content on a statically generated site: enable and disable routes, the bypass cookie, secrets and safe redirects.
  4. 31 Streaming with Suspense Stop one slow query from blocking a whole page: learn Suspense boundaries, loading.tsx, streamed HTML and progressive rendering in Next.js with live stand-ins.
  5. 32 Partial Prerendering Learn Partial Prerendering in Next.js 16: a static shell served instantly with dynamic parts streamed in, how Cache Components enable it, and its tradeoffs.
  6. 33 Node.js and Edge Runtimes Learn the two Next.js runtimes: the full Node.js runtime and the lightweight Edge runtime, what Edge cannot do, how regions matter and when to pick each.

Mutations and Forms

  1. 34 Server Actions Learn Next.js Server Actions: the use server directive, file-level and inline actions, form actions, progressive enhancement and how a call becomes a POST.
  2. 35 Building Forms with Server Actions Build Next.js forms with Server Actions: read FormData, return errors with useActionState, show pending state with useFormStatus and keep user input.
  3. 36 Validating Input Never trust the client: validate Server Action input on the server, return field errors, and share one Zod schema between browser and server code.
  4. 37 Optimistic UI and Refreshing After Mutations Make mutations feel instant with useOptimistic, then show real data with revalidatePath, redirect and router.refresh. Includes live rollback demos.
  5. 38 Route Handlers Build HTTP endpoints in the Next.js App Router with route.ts: GET and POST, Request and Response, dynamic segments, streaming, caching and CORS.
  6. 39 Cookies and Headers Read and set cookies in Next.js with cookies() and headers(): where writing is allowed, httpOnly and sameSite options, and why layouts that read cookies go dynamic.

Middleware, Proxy and Auth

  1. 40 Middleware and the Proxy File Learn what Next.js middleware does, how it became proxy.ts in version 16, how the matcher works, and how to redirect, rewrite and add headers, plus its limits.
  2. 41 Authentication and Sessions Build authentication in Next.js from first principles: password hashing, cookie sessions, signed tokens versus database sessions, a login flow and protected pages.
  3. 42 Authorization and Data Security Learn why Next.js proxy checks are not enough: verify access in every Server Action, Route Handler and data function, use roles, ownership checks and DTOs.
  4. 43 Auth.js, Better Auth and Clerk Compare Auth.js, Better Auth and Clerk for Next.js: how the OAuth flow works with state and PKCE, what each library gives you, and how to choose and wire one up.

Optimization and SEO

  1. 44 Image Optimization with next/image Learn the Next.js Image component: width and height, fill, sizes and srcset, priority loading, remote patterns, formats and how to stop layout shift.
  2. 45 Fonts and Third-Party Scripts Load web fonts without layout shift using next/font, and load analytics or widgets without blocking the page using next/script strategies in the App Router.
  3. 46 Metadata and SEO Set titles, descriptions, Open Graph cards, canonical URLs, sitemaps, robots rules and JSON-LD in the Next.js App Router, and learn how metadata merges.
  4. 47 Generating Open Graph Images Generate social preview images in Next.js with opengraph-image.tsx and ImageResponse, add twitter-image, icons and generateImageMetadata, and avoid the common limits.
  5. 48 Styling in Next.js Compare the ways to style a Next.js App Router app: global CSS, CSS Modules, Tailwind, Sass and CSS-in-JS, and why runtime CSS-in-JS clashes with Server Components.
  6. 49 Using Material UI and Other Component Libraries Use Material UI in the Next.js App Router with the Emotion cache registry, theme provider and client boundaries, and compare shadcn/ui, Radix, Chakra and others.
  7. 50 Bundle Size and Core Web Vitals Cut JavaScript with next/dynamic and lazy loading, find heavy code with a bundle analyzer, and improve LCP, CLS and INP in a Next.js app. Includes the React Compiler option.
  8. 51 Internationalization Build a multilingual Next.js site: locale in the URL, language detection in the proxy file, server-side dictionaries, hreflang tags and Intl formatting.

Configuration, Tooling and Testing

  1. 52 Configuring Next.js A tour of next.config.ts: typed config, redirects versus rewrites, custom headers, env, image settings, output modes, and the experimental flags to treat with care.
  2. 53 Environment Variables and Secrets Learn how Next.js loads .env files, which variables reach the browser with NEXT_PUBLIC_, what is fixed at build time and how to validate configuration at startup.
  3. 54 TypeScript, ESLint and Typed Routes Set up TypeScript and ESLint in Next.js: tsconfig options, typed props for pages and layouts, PageProps helpers, typed routes, lint rules and the Biome option.
  4. 55 Testing Next.js Apps Test a Next.js app with the right tool for each layer: unit tests for logic, Vitest or Jest for components, Playwright for async server components and full flows.
  5. 56 MDX in Next.js Use MDX in the Next.js App Router: set up @next/mdx, map Markdown to your own components with mdx-components.tsx, add remark and rehype plugins, and read frontmatter.
  6. 57 Debugging and Error Handling Debug a Next.js app step by step: the dev overlay, hydration mismatch errors, server and browser logs, breakpoints, instrumentation.ts error reporting and build errors.

Deployment and Production

  1. 58 Building and Deploying Understand what next build produces, how to read its route table, when to use next start, static export or Vercel, and run a checklist before you go live.
  2. 59 Self-Hosting and Docker Run Next.js on your own servers: standalone output, a multi-stage Dockerfile, a reverse proxy, shared cache handlers for several instances, ISR and the image optimizer.
  3. 60 Observability and Scaling Run Next.js in production with confidence: OpenTelemetry traces, structured logs, CDN cache headers, a shared cache, rate limiting and security headers.
  4. 61 Security Headers and Content Security Policy Add HSTS, X-Frame-Options, Referrer-Policy and Permissions-Policy with next.config headers(), then build a nonce-based Content Security Policy in the proxy file.
  5. 62 Upgrading and Migrating from Pages Router Upgrade to Next.js 15 and 16 with codemods, handle async request APIs and caching changes, and move a Pages Router app to the App Router step by step.

Projects

  1. 63 Project: A Markdown Blog Build a fast, SEO-friendly Markdown blog in Next.js: file-based posts, generateStaticParams, metadata, a sitemap and the MDX option, with runnable stand-ins.
  2. 64 Project: An Admin Dashboard Build an admin dashboard in Next.js: nested layouts, URL-driven filters and sorting, a paginated table, Suspense streaming and loading skeletons.
  3. 65 Project: A Todo App with Server Actions Build a todo app with Server Actions: a form with validation, optimistic updates, revalidation and a small database layer, plus runnable stand-ins.
  4. 66 Project: A Storefront with Cart Build a small Next.js storefront: product pages with ISR, a cookie cart, server-side pricing, a checkout action and search, with runnable Node stand-ins.
  5. 67 Project: Login and Protected Pages Build a complete login system in Next.js: database sessions, a secure cookie, a proxy guard, a data access layer and an admin-only page, with runnable stand-ins.
  6. 68 More Projects: Quiz, Weather Dashboard, Expense Tracker, Real-Time Chat Four more Next.js project plans with runnable logic: a quiz app, a weather dashboard with caching, an expense tracker with Server Actions, and a real-time chat using streaming.

Practice and Interviews

  1. 69 Exercises with Solutions Ten Next.js exercises with runnable solutions on routing, the server and client boundary, caching, Server Actions and forms, plus hints you can open when stuck.
  2. 70 UI Recipes: Carousel, Video, YouTube Embed, Modal, Date Picker, Spinner Build common UI widgets in the Next.js App Router: an accessible carousel, modal, date picker and spinner, plus video and YouTube embeds and lazy loading with next/dynamic.
  3. 71 Next.js Interview Questions Next.js interview questions with concise answers on the App Router, Server Components, caching, rendering modes, Server Actions, proxy and deployment, plus runnable demos.
  4. 72 Next.js Cheat Sheet A compact Next.js App Router cheat sheet: commands, special files, nesting order, directives, navigation hooks, caching APIs, Server Actions, metadata and config options.