Interview Q&A · questions with model answers
Next.js Developer Interview Questions
Part of the study plan for: Frontend Engineer · Full Stack Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked What is the difference between Server Components and Client Components?
Server Components render only on the server: they can be async, access databases and secrets directly, and send no JavaScript for themselves to the browser. Client Components (marked with 'use…
-
Most asked What are Route Handlers and when should you use them instead of Server Actions?
Route Handlers (app/api/.../route.ts) export functions named after HTTP methods (GET, POST, ...) using Web Request/Response APIs. Use them for public REST endpoints, webhooks, third-party callbacks,…
-
Which props can be passed from a Server Component to a Client Component?
Serializable values: strings, numbers, booleans, null/undefined, plain objects and arrays, Dates, Maps/Sets, typed arrays, Promises (consumed with use()), JSX elements, and Server Actions. Regular…
-
What's the difference between the Node.js and Edge runtimes in Next.js?
The Node.js runtime supports all Node APIs and npm packages; the Edge runtime is a lightweight V8-isolate environment with Web APIs only, which starts fast and runs close to users but can't use many…
-
What's the difference between React's `cache()` and Next.js's `unstable_cache`?
React cache() memoizes a function for the duration of a single server request (deduplication across components). unstable_cache (being superseded by 'use cache') persists results across requests in…
-
How do API Routes in the Pages Router differ from Route Handlers?
Pages Router API routes (pages/api/*.ts) export a default (req, res) handler using Node-style request/response objects; App Router Route Handlers export named HTTP-method functions using Web…
-
When does `<Link>` prefetch, and how can you control it?
In production, <Link> prefetches routes when they enter the viewport: static routes fully, dynamic routes up to the nearest loading.tsx boundary. prefetch={false} disables it; prefetch={true}…
-
When would you use a custom Node server with Next.js, and what do you lose?
A custom server (Express/Fastify wrapping Next's request handler) suits integrating with existing servers or WebSockets on self-hosted Node. You lose some deployment targets (serverless, Vercel) and…
-
How does Next.js compare with Remix/React Router v7 and Astro?
Next.js offers a full RSC-based framework with flexible caching and rendering modes. React Router v7 (Remix's successor) focuses on web-standard loaders/actions and nested routing with simpler…
-
When would you use `template.tsx` instead of `layout.tsx`?
Use a template when a wrapper must remount on every navigation, for example to replay enter animations, reset form state, or re-run effects like page-view logging per route.
-
Compare Auth.js, Clerk and rolling your own authentication in Next.js.
Auth.js (NextAuth v5) is open source and self-hosted, with OAuth providers and adapters for your DB; Clerk is a hosted service with prebuilt UI, user management and organizations; custom auth gives…
-
How do you rate limit Server Actions or Route Handlers in Next.js?
Use a shared store (Upstash Redis with @upstash/ratelimit, or your own Redis) keyed by user ID or IP (from trusted headers), check limits at the start of the action/handler, and return a 429 or an…