Next.js Junior interview questions and answers
75 questions for a Next.js (Junior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.What is colocation in the App Router?
- 2.What is Next.js?
- 3.How do you create a page at
/aboutin the App Router? - 4.How does
layout.tsxdiffer frompage.tsx? - 5.What must the root
app/layout.tsxcontain? - 6.How do you create a dynamic route
/blog/:slug? - 7.How do you correctly read
paramsin a Next.js 16 page? - 8.Why is
<Link>fromnext/linkbetter than a plain<a href>for internal navigation? - 9.What kind of components are files in the
app/folder by default? - 10.A component uses
useStateandonClickbut crashes with an error. What's missing? - 11.What is the
loading.tsxfile for? - 12.Why must
error.tsxbe a client component? - 13.How do you show a 404 page for a nonexistent product in a server page?
- 14.How do you set a page's title and description in the App Router?
- 15.At what URL is the file
public/logo.pngserved? - 16.How do you create a
GET /api/usersAPI endpoint in the App Router? - 17.Which environment variables are available in browser code?
- 18.What does the
<Image>component fromnext/imagegive you? - 19.Why does
<Image src="https://cdn.example.com/a.jpg" ... />produce a configuration error? - 20.What does
next/fontdo? - 21.Where do you import
useRouterfrom in the App Router? - 22.How do you get the current path in a client component, e.g. to highlight the active link?
- 23.How does SSR differ from SSG?
- 24.What is ISR (Incremental Static Regeneration)?
- 25.When does
getServerSidePropsrun in the Pages Router? - 26.What does
getStaticPathsdo in the Pages Router? - 27.What does a folder in parentheses do, e.g.
app/(marketing)/about/page.tsx? - 28.Why give a folder a name with an underscore, e.g.
app/_components? - 29.Which route will catch
/docs/a/b/c? - 30.What do the
next buildandnext startcommands do? - 31.Which bundler does Next.js 16 use by default for
next devandnext build? - 32.In Next.js 16, what is the file formerly called
middleware.tsnamed? - 33.How do you redirect the user to
/loginfrom a server component? - 34.How do you get the
?page=2query parameter in a server page? - 35.How do you load data in a server component?
- 36.Where do you import global CSS in the App Router?
- 37.Where does a
console.logfrom a server component appear? - 38.What do you pass to
<Image>for an image that stretches over the whole parent block? - 39.How do you lazy-load a heavy client component in Next.js?
- 40.Why load third-party scripts via
next/script? - 41.How do you build a Next.js app into a set of static files without a Node.js server?
- 42.What happens if
app/dashboard/contains bothpage.tsxandroute.ts? - 43.How does
template.tsxdiffer fromlayout.tsx? - 44.Can you use the
useStateanduseEffecthooks in a server component? - 45.When does
<Link>prefetch a route? - 46.Will state in a sidebar inside a shared layout survive navigation between pages?
- 47.How do you type the props of
app/blog/[slug]/page.tsxin Next.js 16? - 48.What is the minimum Node.js version required for Next.js 16?
- 49.Can you use CSS Modules in Next.js without extra configuration?
- 50.What title does the page get with
export const metadata = { title: 'Profile' }in the page andtitle: { template: '%s | Shop', default: 'Shop' }in the layout? - 51.How does a client component read the
[slug]segment of the current URL? - 52.How do you generate
sitemap.xmlin the App Router? - 53.Which file controls the
/robots.txtresponse? - 54.How do you set the site favicon in the App Router?
- 55.How does
permanentRedirect()differ fromredirect()? - 56.How do you redirect the old
/blog/:slugURLs to/news/:slugfor every request, without code in pages? - 57.What happened to the
next lintcommand in Next.js 16? - 58.Can the
app/folder live insidesrc/? - 59.When should you use
router.push()instead of<Link>? - 60.What does the
replaceprop do on<Link>? - 61.What does
scroll={false}on<Link>do? - 62.What is the
useLinkStatushook for? - 63.How do you handle
POST /api/postsin a Route Handler? - 64.Is the
altprop required onnext/image? - 65.Which
.envfile is meant for local secrets and should not be committed? - 66.Why does
export const metadatain a'use client'page cause an error? - 67.Which pages does
app/dashboard/layout.tsxwrap? - 68.Where do you set
themeColorin Next.js 16? - 69.How do you add a web app manifest for a PWA?
- 70.Do you need
'use client'at the top of every client component file? - 71.How do you add JSON-LD structured data to a page?
- 72.How does a server component read a request header like
user-agent? - 73.What does
export const dynamicParams = falsedo on a page withgenerateStaticParams(without Cache Components)? - 74.How do you serve the whole app under
/docs(e.g.acme.com/docs)? - 75.Which
next/scriptstrategy loads a script during browser idle time, e.g. a chat widget?