Next.js Curriculum

Debugging & Production Anti-Patterns

Senior interview rounds frequently test candidates on real-world troubleshooting scenarios and subtle framework traps.Diagnose and fix React hydration mismatches caused by browser extensions, date formatting, and invalid HTML tag nesting.Debug why redirect() throws when wrapped in generic try/catch blocks, prevent cache poisoning leaks in shared server environments, and resolve infinite redirect loops in edge routing matchers.

Lesson 01Hard35 min

Hydration Mismatch: Root Causes & Systematic Debugging

A hydration mismatch occurs when the HTML prerendered on the server does not strictly match the DOM generated by the client during initial React hydration. Common root causes include browser-only APIs (window, localStorage), client-side date/timezone formatting, invalid HTML nesting (e.g. <p> inside <p> or <div> inside <p>), and browser extensions injecting attributes.

Lesson 02Hard30 min

Stale Router Cache Traps After Non-Server-Action Mutations

When mutations are executed outside of Server Actions—such as via direct fetch() to external REST APIs or third-party webhooks—the Next.js client-side Router Cache remains unaware of the change. Navigating back to the page displays stale cached RSC payloads. Developers must programmatically purge the cache using useRouter().refresh() or route segment revalidation.

Lesson 03Medium25 min

Next.js Redirect Exception Suppression in try/catch Blocks

In Next.js, redirect() and notFound() intentionally throw internal JavaScript exceptions (NEXT_REDIRECT and NEXT_NOT_FOUND) to interrupt control flow. A notorious bug occurs when developers wrap Server Actions or Route Handlers in generic try/catch blocks that catch these framework exceptions, mistaking them for application errors and suppressing navigation.

Lesson 04Hard35 min

Cache Poisoning & Cross-User Data Leaks in Shared Environments

A catastrophic security vulnerability occurs in Next.js when user-specific private data (e.g. account balances, profile emails, auth tokens) is cached in the shared server Data Cache or Full Route Cache. Subsequent visitors then receive the first user's cached private information from the CDN or server cache without ever hitting the database.

Lesson 05Hard30 min

Network Interceptor Traps: Regex Catastrophes and Infinite Loops

Network interceptors (middleware.ts and proxy.ts) execute before every HTTP request. Fatal production anti-patterns include: 1) Flawed matcher regexes that intercept internal static assets (/_next/static, favicon.ico), 2) Infinite redirect loops caused by redirecting to a route that triggers the same redirect condition, and 3) Catastrophic backtracking in poorly structured regular expressions (ReDoS).