Next.js App Router in Production: 7 Patterns for Fast Pages
The Next.js App Router changes how you think about rendering. Pages are built from React Server Components by default, data fetching happens on the server and only the interactive parts ship JavaScript to the browser. Used well, this gives fast pages and strong SEO. These are the seven patterns I rely on, and this portfolio is built with them.
Key takeaways
- Keep components on the server by default and push
"use client"down to small leaves. - Fetch in parallel, and stream slow parts behind
Suspense. - Generate pages statically whenever the content allows it.
- Let
next/image,next/fontand the Metadata API handle the details that affect Core Web Vitals and SEO.
1. Server Components by default
A Server Component runs only on the server and sends rendered output, not its JavaScript. Keep layout, content and data access there. Add "use client" only for the pieces that need state, effects or browser APIs, such as a menu toggle or a form with live validation. Pushing that boundary down to leaf components keeps the client bundle small.
2. Fetch data in parallel
Awaiting requests one after another creates a waterfall. Start independent requests together:
export default async function Page() {
const [profile, projects] = await Promise.all([getProfile(), getProjects()]);
return <Dashboard profile={profile} projects={projects} />;
}3. Stream slow content
If one section depends on a slow request, do not hold up the whole page. Wrap it in Suspense so the rest renders immediately and the slow section streams in with a fallback.
<Suspense fallback={<ReviewsSkeleton />}>
<Reviews />
</Suspense>;4. Prefer static generation
A page that can be built once and served from a CDN is the fastest page you can ship. For content that comes from a known list, such as blog posts or project pages, generate every route at build time and return a 404 for anything else:
export const dynamicParams = false;
export function generateStaticParams() {
return posts.map((post) => ({ slug: post.slug }));
}Caching and revalidation APIs have changed across recent Next.js releases, so check the documentation for your version before relying on a specific behaviour.
5. Use next/image and next/font
Images and fonts are common causes of poor Largest Contentful Paint and layout shift.
- `next/image` serves correctly sized, modern formats and reserves space using the width and height you provide, which prevents layout shift. Mark the main above-the-fold image with
priority. - `next/font` self-hosts fonts, removes extra network requests to font providers and avoids a flash of unstyled text when you set
display: "swap".
6. Use the Metadata API and file conventions
SEO basics live in code, which keeps them consistent:
generateMetadatafor per-page titles, descriptions, canonical URLs and Open Graph datasitemap.jsandrobots.jsfor crawlersopengraph-image.jsxto generate social images- a JSON-LD component for structured data
Together these cover most of technical SEO without a plugin.
7. Split heavy client code
Large charting, editor or animation libraries should not load on every page. Import them dynamically where they are used, so they only download when needed:
import dynamic from "next/dynamic";
const Chart = dynamic(() => import("./Chart"), { ssr: false });Then measure. Run a production build and look at what each route ships before deciding what to split.
A short audit for your own app
- Search for
"use client"and ask whether each one can move lower in the tree. - Look for sequential
awaitcalls that could run together. - Check that every image has dimensions and the hero uses
priority. - Confirm every indexable page has a unique title, description and canonical URL.
- Run Lighthouse on a production build, not the dev server.
I build and tune Next.js applications as part of my web application development service, and the performance work that goes with it.
- Next.js
- React Server Components
- performance
- App Router
- SEO