How to Audit a Next.js App Router Codebase
For Technical leads auditing an existing Next.js codebase · Based on Codynn Next.js Full-Stack App Builder
// TL;DR
Technical leads can use this framework as an audit checklist for any Next.js App Router codebase. It defines what correct looks like: Server Components by default with 'use client' only where justified, folder-based routes matching the intended URL tree, Link instead of anchor tags, awaited params in dynamic routes, server-rendered metadata for SEO, and stable keys in lists. Use it to catch performance regressions from over-used client components, routing bugs from misnamed files, and SEO gaps from manual head tags — and to give developers concrete, convention-based feedback.
What should I check first when auditing a Next.js App Router project?
Start with the Server vs Client boundary, because it's where most performance regressions hide. The convention is Server Components by default; `'use client'` should appear only when a component uses `useState`, `useEffect`, `useRouter`, `usePathname`, `useSearchParams`, event handlers, or browser APIs. Search the codebase for `'use client'` directives and flag any high-level component that forces its entire subtree to the client. The fix is to push `'use client'` down to the smallest interactive leaf, keeping the bulk of the UI server-rendered and the bundle small.
How do I verify the routing is correct?
Compare the `app/` folder tree to the intended URL map. Confirm every route folder contains a file named exactly `page.tsx` — misnamed files silently fail to register as routes. Check for organizational folders that aren't wrapped in parentheses; an unwrapped folder becomes an unintended URL segment. Verify Route Groups `(name)` are used where URL-free organization is intended, and that dynamic `[slug]` and catch-all `[...slug]` folders match the data model.
For dynamic routes, confirm the page function is `async` and that `params` is awaited — in modern Next.js, params is a Promise. A common bug is accessing `params.slug` directly, which returns a pending Promise instead of the value.
What are the highest-impact pitfalls to flag?
Check that data is fetched in Server Components where possible — they can `await` directly, keep secrets server-side, and ship no fetching code to the client. For query-string-driven UI, the correct pattern is a small Client Component using `useSearchParams` rendered inside a Server Component page, so the page stays server-rendered. For the API, verify endpoints are `route.ts` files exporting HTTP-method functions and returning `NextResponse.json()`, following the same folder-based routing.
How do I evaluate loading, error, and SEO coverage?
Confirm the special files are present where they add value: `loading.tsx` for automatic loading UI, `not-found.tsx` for custom 404s, and `error.tsx` for runtime error boundaries. These activate by convention with no registration. For SEO, verify each public page exports its own `metadata` with unique title and description, and that fonts are imported from `next/font/google` for self-hosting and no layout shift.
What does a good audit deliverable look like?
Produce a checklist-based report grouped by severity: correctness bugs (misnamed files, un-awaited params, missing exports), performance issues (over-used `'use client'`, anchor navigation), and SEO gaps (manual head tags, missing metadata). Tie each finding to the specific Next.js convention it violates so developers get concrete, actionable feedback.
// FREQUENTLY ASKED QUESTIONS
What's the most common performance issue in a Next.js App Router codebase?
Over-using 'use client'. Marking high-level components as Client Components forces their entire subtree to ship JavaScript to the browser, inflating the bundle. The fix is defaulting to Server Components and pushing 'use client' down to the smallest interactive leaf. Audit by searching for 'use client' directives placed too high in the tree.
How do I spot routing bugs during a Next.js audit?
Compare the app/ folder tree to the intended URL map. Flag route folders missing a file named exactly page.tsx, organizational folders not wrapped in parentheses that create unintended URL segments, and dynamic route pages that access params without awaiting it. Also confirm every page file has a default export, or it won't register as a route.
How do I check that a Next.js app is SEO-ready?
Verify each public page.tsx exports a metadata object of type Metadata with a unique title and description, rendered server-side in the head. Flag any manual head tags in JSX, since they aren't guaranteed to be server-rendered for crawlers. Also confirm fonts come from next/font for self-hosting and no layout shift, which aids Core Web Vitals.