completefrontend
NEXT.JS INTERVIEWS

Next.js interview questions

148 questions about Next.js, the way interviewers ask them: 77 to explain, 40 where you say what a real app answers, shows, or prints, and 31 where you write a file of an app. 52 easy, 66 medium, and 30 hard. Every output answer is what Next.js 16.4.3 did when the app was built and run, and every code answer passes its tests.

Every question is free to read. Sign in with Google to see the answers: the short version to say in the interview, why it's true, and what they'll ask next.

148 of 148 questions

Basics & project structure

  1. What does Next.js add to React, and when would you build without it?ConceptEasy
  2. What's the difference between the App Router and the Pages Router, and can one app use both?ConceptEasy
  3. What does create-next-app set up by default, and what is each top-level file and folder for?ConceptEasy
  4. What do next dev, next build, and next start each do, and why shouldn't you judge speed with next dev?ConceptMedium
  5. One page is a Server Component and the other starts with "use client". What does next build print for each?Predict the outputEasy
  6. What happens when a Next.js page first loads, and what's different when you then follow a <Link>?ConceptHard
  7. Two pages call console.log while they render. What prints during next build, and what for each request?Predict the outputHard
  8. How do you type a page's params and searchParams, and where do PageProps and LayoutProps come from?ConceptMedium
  9. A Server Component and a Client Component both read NEXT_PUBLIC_SHOP_NAME and SUPPLIER_NAME. What does each show?Predict the outputMedium
  10. Write redirects() in next.config.ts for a shop that moved its pagesWrite the codeMedium
  11. Move a Pages Router page that uses getServerSideProps to the App RouterWrite the codeMedium

Routing & navigation

  1. How do folders in app become routes, and what do [slug], [...slug], and [[...slug]] put in params?ConceptEasy
  2. When do you navigate with <Link>, and when with router.push?ConceptEasy
  3. What's the difference between redirect, permanentRedirect, and router.replace?ConceptEasy
  4. Write a NavLink that marks itself when it points to the current page or its sectionWrite the codeEasy
  5. What's the difference between a layout and a template, and what renders again when you navigate?ConceptMedium
  6. Which hooks read the URL in Next.js, why are they client-only, and how does a Server Component read the same thing?ConceptMedium
  7. A counter lives in a layout. What does it show after you follow a <Link>, and then a plain <a>?Predict the outputMedium
  8. Write a tea page that reads its tea from params and the number of cups from searchParamsWrite the codeMedium
  9. Write previous and next links for the teas layout, with arrow-key shortcutsWrite the codeMedium
  10. What does <Link> prefetch, and when? How long does the router keep it, and what happens on Back?ConceptHard
  11. You type a note on a tea page, open another tea, then come back with Back and with a <Link>. What's kept, and what renders again?Predict the outputHard
  12. With generateStaticParams and notFound() in a dynamic route, what do /teas/mint and /teas/rooibos answer?Predict the outputHard

Special files, errors & advanced routing

  1. In what order does Next.js nest layout, template, error, loading, not-found, and page in one folder, and why does it matter?ConceptEasy
  2. How does error.tsx work? Why must it be a Client Component, how do reset and retry differ, and when do you need global-error.tsx?ConceptMedium
  3. A tea page has loading.tsx and error.tsx, and one tea's stock check throws. What does the server answer, and what does the browser show?Predict the outputHard
  4. Write global-error.tsx for when the root layout itself failsWrite the codeMedium
  5. How is notFound() different from a URL that matches no route, and where do forbidden() and unauthorized() fit?ConceptMedium
  6. Write a not-found.tsx for tea pages that suggests teas in stockWrite the codeEasy
  7. What are route groups and private folders, and how do you give the shop and the staff area different root layouts?ConceptEasy
  8. An account layout has an @orders slot, and you add a settings page. What does next build say?Predict the outputEasy
  9. How do parallel routes and intercepting routes give a modal its own URL, and what does a refresh show?ConceptMedium
  10. A tea opens in a modal from the list. What shows after you click Cart, press Back, and reload?Predict the outputHard
  11. Add previous and next links to an intercepted tea modal, so one Back still closes itWrite the codeMedium

Server & Client Components

  1. What is the difference between Server Components and Client Components in Next.js, and how do you choose?ConceptEasy
  2. What does "use client" actually mark, and does a Client Component only run in the browser?ConceptMedium
  3. Can a Client Component render a Server Component? How do you put server-rendered UI inside one?ConceptEasy
  4. A Client Component hides its server-rendered children until a click. What runs during next build, and what does the click change?Predict the outputHard
  5. Write a ReadMore Client Component that hides server-rendered content until it's openedWrite the codeEasy
  6. A useState component without "use client" works inside a Client Component. What happens when a Server Component page renders it too?Predict the outputEasy
  7. What can a Server Component pass as props to a Client Component, and what happens when it passes something it can't?ConceptMedium
  8. An async component is imported into a Client Component instead of being passed in. Does the build pass, and what happens in the browser?Predict the outputMedium
  9. Use a third-party slide show that needs useState and a render function on a Server Component pageWrite the codeMedium
  10. Write a context provider that shares the signed-in customer with Client Components, without making the pages waitWrite the codeMedium
  11. How do you keep server code out of the browser? What do server-only, client-only, and the NEXT_PUBLIC_ prefix do?ConceptEasy
  12. Server Components can't use context. How do a layout, a page, and generateMetadata share data without loading it three times?ConceptHard

Fetching data & streaming

  1. How do you fetch data in the App Router, and why don't you need an API route to read your own database?ConceptEasy
  2. What's a request waterfall in a Server Component tree, and how do you avoid one with Promise.all, sibling components, or preloading?ConceptMedium
  3. A teammate rewrites two awaits as one Promise.all. In what order do the log lines print, before and after?Predict the outputEasy
  4. Write a tea page that fetches three things from an API in parallel and copes with failures and empty answersWrite the codeMedium
  5. How does streaming work in the App Router, and when do you use loading.tsx instead of your own <Suspense>?ConceptEasy
  6. A tea page has a cached description, then a slow and a fast <Suspense>. What's in the first HTML, and what appears in what order?Predict the outputHard
  7. Is fetch cached in Next.js 16? What's the difference between request memoization and caching?ConceptMedium
  8. Four components fetch the same URL, one with cache: "no-store" and one with a timeout signal. How many requests reach the API?Predict the outputHard
  9. What does connection() do with Cache Components, and when do you need it instead of cookies(), headers(), or a fetch?ConceptMedium
  10. When should a Client Component fetch with SWR or React Query, and when should the server fetch the data, or pass a promise to use()?ConceptMedium
  11. Write a review list that reads a Server Component's promise with use(), and filters it in the browserWrite the codeMedium
  12. Write a data function that asks the database only for what the tea list needs, and returns only those fieldsWrite the codeEasy

Server Actions, forms & Route Handlers

  1. What is a Server Action, and what happens when a form calls one?ConceptEasy
  2. Two forms with Server Actions are sent before the page's JavaScript loads. What does the server answer, and what does the next visitor see?Predict the outputHard
  3. "use server" at the top of a file or inside a function: what's the difference, and what happens to the values an inline action uses?ConceptHard
  4. How should a Server Action report a validation error: return it or throw it?ConceptEasy
  5. Write a Server Action that checks a tasting-box order and returns each field's error to useActionStateWrite the codeMedium
  6. Write a Server Action that adds a tea to a cart kept in a cookieWrite the codeMedium
  7. How do useFormStatus, useActionState, useTransition, and useOptimistic help while a Server Action runs?ConceptMedium
  8. After a Server Action saves a change, how do you update the page: revalidatePath, updateTag, revalidateTag, refresh, or redirect?ConceptMedium
  9. One button's Server Action calls revalidatePath and the other's doesn't. What does the page show after each click?Predict the outputMedium
  10. When do you use a Server Action, and when a Route Handler?ConceptEasy
  11. A Route Handler exports only GET and POST. What do HEAD, OPTIONS, and DELETE requests get?Predict the outputEasy
  12. Write a Route Handler that partner sites can call from the browser, with CORS and a preflightWrite the codeMedium

Rendering: static, dynamic & PPR

  1. One page reads cookies() inside <Suspense> and the other reads nothing. Is each route static or dynamic?Predict the outputMedium
  2. What are SSR, SSG, ISR, and CSR, and what do they become in the App Router?ConceptEasy
  3. What makes a page dynamic in Next.js 16, and how does Cache Components change the answer?ConceptEasy
  4. What is Partial Prerendering? What goes into the static shell, and how do the dynamic parts reach the browser?ConceptHard
  5. A page reads searchParams, one has generateStaticParams, and two wait for connection(). What does the route table print?Predict the outputMedium
  6. How does generateStaticParams work with Cache Components when it lists every param, some, or none? Does dynamicParams still apply?ConceptMedium
  7. The greeting is inside <Suspense>, but the page awaits headers() itself. What does next build say?Predict the outputEasy
  8. generateStaticParams lists only Green tea. What do the first and second visits to /teas/oolong get, and what does the terminal print?Predict the outputHard
  9. What's the difference between server rendering and hydration, and what does making a page dynamic cost?ConceptMedium
  10. When should a page be fully static, and how do you keep it static as the app grows?ConceptEasy
  11. Split the home page so the tea of the week is prerendered and only its stock is rendered for each requestWrite the codeMedium
  12. Prerender only each category's two best sellers with a generateStaticParams that gets its category from the layoutWrite the codeMedium

Caching & revalidation

  1. The older App Router had four caches. What were they, and what does each become with Cache Components?ConceptMedium
  2. Where can you put "use cache", and what decides whether two calls share a cached result?ConceptEasy
  3. A "use cache" component logs when it renders. What does the terminal print for four visits to the same page?Predict the outputEasy
  4. What do stale, revalidate, and expire mean in cacheLife, and how do they give you ISR in the App Router?ConceptEasy
  5. Move a data layer from fetch's cache options to "use cache", cacheLife, and cacheTagWrite the codeEasy
  6. A cached component renders a price that reads cookies() inside its own <Suspense>. Does next build pass?Predict the outputMedium
  7. What do "use cache: private" and "use cache: remote" change, and when would you use each instead of "use cache"?ConceptMedium
  8. What happens when you call revalidateTag("teas", "max")? How does Next.js find and refresh everything tagged teas?ConceptMedium
  9. A webhook revalidates one price tag with "max" and another with { expire: 0 }. What do the next three pages show?Predict the outputHard
  10. A customer posts a review. Which cached data should the Server Action expire with updateTag, and which with revalidateTag?Write the codeMedium
  11. What does router.refresh() do, and why doesn't it show new data from a "use cache" function?ConceptMedium
  12. Write a "use cache: remote" cache handler that three self-hosted servers share, tags includedWrite the codeHard

proxy.ts, i18n & multi-tenancy

  1. What is proxy.ts, and why did Next.js 16 rename middleware.ts? What still works with the old name?ConceptEasy
  2. proxy.ts redirects /shop, rewrites /menu, and answers /api/stock itself. What does each request get?Predict the outputEasy
  3. proxy.ts runs on Node.js. What does that let it do, and what should you still keep out of it?ConceptMedium
  4. proxy.ts has no matcher and logs each request. What does it print when you open the home page, scroll to a link, and click it?Predict the outputMedium
  5. Fix a proxy.ts that sends mixed-case addresses like /Teas/Mint-Tea to their lowercase pageWrite the codeEasy
  6. next.config.ts redirects /shop and rewrites /team to /staff, and proxy.ts guards /shop and /staff. What gets through?Predict the outputHard
  7. Why shouldn't proxy.ts be your only auth check? What did CVE-2025-29927 show?ConceptHard
  8. How do you build a site in several languages with the App Router, and how is it different from the Pages Router's i18n config?ConceptEasy
  9. Keep English pages at /teas and French ones at /fr/teas, with every page under app/[lang]Write the codeMedium
  10. How do you serve many shops, each on its own domain or subdomain, from one Next.js app?ConceptMedium

Styling, images, fonts & metadata

  1. How do you style an App Router app? Where do global CSS, CSS Modules, Tailwind, and CSS-in-JS each fit?ConceptEasy
  2. What does next/image do that a plain <img> doesn't, and which props and settings matter?ConceptMedium
  3. Write a custom next/image loader that serves every picture from the shop's image CDNWrite the codeEasy
  4. How does next/font load a Google font, and why doesn't the text jump when the font arrives?ConceptEasy
  5. What are next/script's loading strategies, and when would you use each?ConceptMedium
  6. What is the public folder for, and when should you import a file instead?ConceptEasy
  7. An old public/robots.txt is still there after you add app/robots.ts. What does next build print, and what does /robots.txt answer?Predict the outputMedium
  8. When do you use the metadata object and when generateMetadata? How does Next.js stream metadata, and what do crawlers get?ConceptHard
  9. The root layout has a title template and the teas section has a layout with a plain title. What title does each page get?Predict the outputHard
  10. Tea pages and journal posts each have an opengraph-image.tsx, and both pages list their slugs. What does next build print?Predict the outputMedium
  11. Split a 120,000-page marketplace into sitemaps of 50,000 URLs with generateSitemapsWrite the codeHard

Auth & security

  1. What's the difference between authentication and authorization, and where does each check go in an App Router app?ConceptEasy
  2. The staff layout shows customers Staff only. in place of its children. What does Asha get for the orders page, and what prints?Predict the outputHard
  3. How do you keep a user signed in to a Next.js app: a signed cookie or a database session? Which cookie options matter?ConceptEasy
  4. Write a change-password Server Action that signs the customer out on every other deviceWrite the codeMedium
  5. Write the callback Route Handler for "Sign in with Teapot ID", with its state and PKCE checksWrite the codeHard
  6. A Server Action and a Route Handler both save questions. What happens when a page on another site posts to each?Predict the outputMedium
  7. Does React protect a Next.js app from XSS? Where can a script still get in?ConceptEasy
  8. Which security headers would you add to a Next.js app, and where do you set them?ConceptEasy
  9. proxy.ts adds a Content Security Policy with a nonce. Which still works: a static page, one with a static shell, or a dynamic one?Predict the outputHard
  10. What do React's taint APIs do in a Next.js app, and why aren't they enough on their own?ConceptMedium
  11. How do you cache data that depends on who's signed in, without showing it to someone else?ConceptMedium

Performance, testing & deploying

  1. How do you measure Core Web Vitals in a Next.js app, and what does Next.js already do for LCP, CLS, and INP?ConceptEasy
  2. A Client Component loads LastBrew with next/dynamic and ssr: false. What's in the HTML, and what does the browser show?Predict the outputEasy
  3. A page sends too much JavaScript. How do you find what's in it, and how do you make it smaller in Next.js?ConceptMedium
  4. Write the function useReportWebVitals calls, so metrics reach your analytics in batches that survive the page closingWrite the codeMedium
  5. How do you test a Next.js app? What can unit tests run, and what needs an end-to-end test?ConceptMedium
  6. What does output: "export" give you, and what stops working in a static export?ConceptEasy
  7. The load balancer checks /api/health. After staff switch on maintenance, what do /api/health and /api/ready answer?Predict the outputMedium
  8. You self-host Next.js in Docker on three servers behind a load balancer. What do the build, the cache, Server Actions, and deployments need?ConceptHard
  9. instrumentation.ts has an async register, and proxy.ts and two pages log too. What does the terminal print, and when?Predict the outputHard
  10. Write onRequestError in instrumentation.ts, so every server error reaches the error tracker without leaking the visitor's dataWrite the codeMedium
  11. What do you check before a Next.js app goes to production?ConceptEasy

How Next.js works inside

  1. What is the RSC payload, and why is it also inside a Next.js page's HTML?ConceptEasy
  2. A Client Component logs when it renders. What does next start print for the page's HTML, and for its RSC payload?Predict the outputMedium
  3. How does a "use client" file become a client reference, and how does the browser find its code?ConceptMedium
  4. What are SWC and Turbopack, and what does each do when you build a Next.js app?ConceptEasy
  5. A Server Component, a Client Component, and a Pages Router page each show React.version. What does each one say?Predict the outputEasy
  6. Walk me through what next start does with a request, from the moment it arrives to the response.ConceptMedium
  7. What does the router send when you click a <Link>, and how does the server know which parts of the page to render?ConceptHard
  8. A layout's basket and a page's stock both log when they render. What prints for a visit, a <Link> click, a refresh, and Back?Predict the outputHard
  9. Write instrumentation-client.ts so the shop's analytics count client-side navigations as page viewsWrite the codeMedium
  10. How does "use cache" work under the hood? What does the compiler generate, and what does Next.js store?ConceptMedium
  11. Nothing in your code says which parts of a page need a request. How does next build find them with Cache Components?ConceptHard