Skip to content
tezvyn:

React & Next.js

React, Next.js, Remix, RSC, React ecosystem

301 bites

Test yourself: Top 30 React & Next.js interview questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Everything in React & Next.js, page 3

easy2 min read

Would you use getServerSideProps or getStaticProps for private user data?

Tests SSR vs SSG privacy. Use getServerSideProps: it runs per-request with auth cookies. getStaticProps bakes HTML/JSON at build time, leaking private data across users. Red flag: suggesting ISR or revalidation for authenticated data.

easy2 min read

How would you implement a basic protected route in React?

Hold auth in useState, pass user to protected components, and return Navigate to login when absent.

easy2 min read

How do you manage Next.js env variables on Vercel and use NEXT_PUBLIC_?

Set DB strings in Vercel dashboard without NEXT_PUBLIC_; consume in server code only. NEXT_PUBLIC_ inlines values into the browser JS bundle, leaking them to all users.

advanced2 min read

Implement a custom next/image loader for a self-hosted service

Tests next/image loader contract and URL construction. A strong answer defines a function taking src, width, and quality; returns a URL string for your service; and wires it via the loader prop or loaderFile config.

advanced2 min read

Implement A/B testing with Middleware rewrites and cookies

Sticky cookie, internal rewrite, vary cache on cookie, server-side analytics.

advanced2 min read

How do you opt out of static rendering for real-time data?

Tests Next.js App Router caching and dynamic rendering escape hatches. Cover force-dynamic SSR, ISR with revalidate, noStore, and client fetching; weigh server load vs staleness. Red flag: only CDN purges without segment config or data cache fixes.

intermediate2 min read

Explain how next/image's sizes prop works for responsive performance

This tests your knowledge of the browser responsive image algorithm. The sizes prop declares the rendered width at each breakpoint so the browser can select the smallest adequate srcset candidate.

intermediate2 min read

How to structure translations and load locale content in App Router

Tests App Router i18n architecture with next-intl. Answer: locale-prefixed routes, JSON message files with ICU syntax, and next-intl APIs consumed in Server Components. Red flag: using client-side locale state instead of integrated routing.

intermediate2 min read

Full Route Cache vs Data Cache and per-fetch cache control

Tests App Router's dual caching layers. Full Route Cache stores rendered HTML and RSC payload at build time; Data Cache stores raw fetch results across routes. Control a fetch with cache and next.revalidate options.

intermediate2 min read

Where Next.js Middleware executes and Edge Runtime limits

Tests your grasp of Edge Runtime constraints. Middleware runs at the Edge before route matching, with no Node.js APIs, require, Buffer, or dynamic eval, only Web APIs. Red flag: treating it as Node.js and suggesting fs or npm packages.

easy2 min read

How do you enable basic i18n routing in Next.js?

This tests your knowledge of the built-in Pages Router i18n configuration in next.config.js. A good answer exports an i18n object with locales array, defaultLocale, and optionally localeDetection.

easy2 min read

What is Next.js Middleware and a real-world auth use case?

This tests request interception before a route renders. A good answer defines Middleware as pre-request code using NextRequest and NextResponse, often on the Edge Runtime, with auth redirects as an example.

easy2 min read

What are the benefits of next/image over a standard img tag?

Tests knowledge of Next.js image infrastructure. Strong answers mention automatic optimization, lazy loading, blur placeholders for layout shift, and responsive srcset. Red flag: calling it a zero-impact wrapper or a styling component.

advanced2 min read

How to securely set and read httpOnly cookies in Route Handlers

This tests cookie security across the App Router. A strong answer covers setting httpOnly, Secure, SameSite via NextResponse in a Route Handler, reading with cookies() later, and why document.cookie cannot access it. Red flag: client-side JavaScript access.

advanced2 min read

How do you implement response streaming in a Next.js Route Handler?

This tests Web Streams API mastery in Next.js. Strong answer: create a ReadableStream with TextEncoder, return it in a Response, and cite AI chat or large JSON as use cases. Red flag: suggesting Node res.write instead of standard Web Streams.

advanced2 min read

How would you use Next.js Middleware to protect /api/admin/* routes?

Match /api/admin/:path*, read the secure cookie, validate the token, return 401 or proceed.

intermediate2 min read

How do you read headers and search params in a Route Handler?

Tests fluency with the Web Standard Request API in Next.js App Router. A strong answer uses request.headers.get() for headers and request.nextUrl.searchParams for query params, avoiding Express-style req.query or req.headers.authorization.

intermediate2 min read

How do you handle multiple HTTP methods in a single route.ts file?

Tests App Router Route Handler REST conventions. A strong answer exports named GET, PUT, DELETE handlers using NextRequest and NextResponse.json, plus 405 for unsupported methods.

intermediate2 min read

How do you create a dynamic API route and access its parameter?

This tests Next.js routing conventions and dynamic parameter extraction. Create /api/products/[productId]/route.js, export a GET handler, and read productId from params. Red flag: mixing App Router params with Pages Router req.query.

intermediate2 min read

GET caching in Route Handlers and how to opt out

Tests App Router GET Route Handler caching and dynamic opt-outs. Hit: export const dynamic = 'force-dynamic', revalidate = 0, dynamic APIs like cookies(), and unstable_noStore(). Red flag: confusing this with Pages Router API routes, dynamic by default.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles