Q1
In Next.js App Router, why does importing a Client Component inside a Server Component work—yet importing a Server Component directly inside a 'use client' file turn it into a Client Component?
Adding 'use client' creates a module boundary: anything imported directly into a Client module gets bundled into browser JS. To nest Server Components inside Client wrappers (like modals/tabs), pass them via children props.
Q2
Why can Next.js generateStaticParams + dynamic headers() or cookies() crash a static build?
Reading per-request headers/cookies opts a route into dynamic runtime rendering, conflicting with static export assumptions. Isolate authenticated user reads inside dynamic segments or Client hooks while keeping SEO landing pages static.
Q3
What causes 'Hydration failed because the initial UI does not match' when rendering user timezone dates or browser storage?
Server Node processes render in UTC/server locale without localStorage or window. Delay client-only formatting until after mount (useEffect) or pass server timestamps cleanly.
Q4
How do revalidatePath, revalidateTag, and cache: 'no-store' differ for CMS-driven Next.js pages?
no-store bypasses cache on every request (higher DB load); revalidatePath/revalidateTag serve fast cached HTML while purging stale entries on-demand the instant an admin saves CMS changes.
Q5
Why does next/link prefetching sometimes trigger unexpected API hits or slow dev navigation?
In production, <Link> prefetches visible viewport route RSC payloads automatically unless prefetch={false} is set—helpful for instant page switches, but costly on pages with hundreds of dynamic links if uncached.
Q6
Why should Next.js Route Handlers validate params with await params in Next.js 15?
Next.js 15 transitioned params and searchParams to asynchronous Promises across pages, metadata, and route handlers so partial/streaming rendering doesn't block synchronously on route parameters.
Q7
Why does placing secrets inside NEXT_PUBLIC_* environment variables expose them publicly?
Next.js inlines every NEXT_PUBLIC_ variable literally into client JS chunks during build. Only prefix public endpoints/analytics IDs; keep DB URLs, SMTP keys, and API tokens strictly un-prefixed on the server.
Q8
What happens if Next.js Middleware matches static _next/static or image paths accidentally?
Running auth redirects or heavy checks on _next/static, /images, or /favicon.ico breaks stylesheets, chunks, and assets. Always exclude static asset paths in export const config = { matcher: [...] }.
Q9
Why is next/image rejecting external image URLs with Invalid src prop—and why avoid wildcard hostnames blindly?
Next.js requires explicit remotePatterns inside next.config to prevent SSRF proxy abuse where attackers fetch arbitrary internal network URLs through /_next/image.
Q10
How does permanentRedirect() (HTTP 308/301) preserve SEO equity differently from client router.push()?
Search crawlers follow server-side 301/308 permanent redirects immediately and consolidate old link equity to the new canonical URL, whereas router.push() only runs in JS after returning HTTP 200 on the stale URL.