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?

- Anchor tags for internal navigation. Every internal `` should be the `Link` component from `'next/link'`. Anchor tags force full-page reloads and discard in-memory state.

- Missing or unstable list keys. Confirm every `map` render has a stable, unique `key` from the data — not the array index for lists that can reorder, which causes incorrect reconciliation.

- Manual `` tags for SEO. These aren't guaranteed to be server-rendered for crawlers. They should be replaced with an exported `metadata` object of type `Metadata` from each `page.tsx`.

- Missing default exports. A page file without `export default` won't render as a route.

- Hooks in Server Components. `useState`, `useEffect`, or navigation hooks without `'use client'` cause build or runtime errors.

How do I assess data fetching and the API layer?

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.

Next step: Run a grep for `'use client'` and `

// FREQUENTLY ASKED QUESTIONS