Next.js Cheatsheet - Next.js Framework Reference
For React developers building full-stack apps who must decide between SSR and SSG. The core of Next.js is not a list of APIs but clarifying who renders on the server, what interacts on the client, and when data goes stale — server components cannot attach onClick, and ISR serves cached data that can lag behind. By the end you can build a practical App Router page and layout, draw the client/server component boundary, weigh static generation vs ISR, and handle middleware and data fetching.
App Router Basics 5
app/page.tsxapp/layout.tsxapp/loading.tsxapp/error.tsxapp/not-found.tsxData Fetching 6
fetch(url, { cache: "force-cache" })fetch(url, { cache: "no-store" })fetch(url, { next: { revalidate: 60 } })generateStaticParams()"use server"server-onlyRendering Strategies 5
export const dynamic = "force-static"export const dynamic = "force-dynamic"export const revalidate = 3600"use client"export const runtime = "edge"Layout & Templates 5
export const metadata = { title: "Page Title" }export async function generateMetadata()app/@modal/default.tsxapp/(...)/[...slug]/page.tsxtemplate.tsxAPI & Middleware 6
app/api/route.tsexport async function GET(request)middleware.tsNextResponse.redirect(new URL("/login", request.url))NextResponse.next()cookies().get("token")Static Assets & Optimization 5
import Image from "next/image"import { Inter } from "next/font/google"import Script from "next/script"export const metadata = { robots: { index: true, follow: true } }<Link href="/about" prefetch={true}>Deployment & Configuration 5
output: "standalone"output: "export"process.env.NEXT_PUBLIC_API_URLnext buildnext startTips
- App Router is the default routing solution in Next.js 13+, replacing Pages Router
- Page components are Server Components by default, add "use client" for client-side interactivity
- Use next/link Link component instead of a tags for automatic prefetching and client-side navigation
- Fetch data directly in Server Components with async/await, no useEffect needed
- Use generateStaticParams for static generation of dynamic routes
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us