Here are the top Next.js interview questions to prepare for your next role.
1️⃣ In the Next.js App Router, which file naming convention is used to define a layout that wraps all pages within a route segment?
- A) appLayout.config.js
- B) segmentLayout.ts
- C) wrapper.jsx
- D) layout.js
2️⃣ What is the main limitation of React Server Components that prevents them from being interactive?
- A) They cannot import external modules
- B) They only support static HTML files
- C) They cannot return JSX
- D) They cannot access browser APIs or handle user events
3️⃣ What is the difference between the [...slug] and [[...slug]] route segments in Next.js?
- A) [...slug] requires at least one segment, while [[...slug]] allows zero or more
- B) [[...slug]] is used only for API routes, while [...slug] is used for pages
- C) [[...slug]] automatically redirects missing segments, while [...slug] does not
- D) [...slug] only matches static routes, while [[...slug]] matches dynamic routes
4️⃣ If you define a dynamic route "[id]" and a static route "about" at the same level in a Next.js project, which route is matched first when both could apply to the incoming URL?
- A) Whichever route was created first
- B) The static route "about"
- C) The dynamic route "[id]"
- D) Whichever route is alphabetically first
5️⃣ What happens when you use dynamic functions like cookies() or headers() in a Server Component?
- A) The component is bundled into a separate chunk
- B) The component is forced to render on the client
- C) The component is automatically memoized by Next.js
- D) The component becomes dynamic and cannot be statically rendered