Unit 1: Fundamentals of Next.js and Routing - Practice Quiz
1 What is Next.js?
2 Which programming library is the foundation of Next.js?
3 Which feature can Next.js use to generate HTML on the server for each request?
4 Which Next.js component provides automatic image optimization?
<Image>
<Head>
<Form>
<Script>
5 Which directory commonly contains routes when using the Next.js App Router?
styles
node_modules, which contains all route definitions written by the developer
public
app
6
What is the main purpose of the public directory in a Next.js project?
7 Which file normally defines the UI for a route in the App Router?
component.config.js, which registers every component used across the application
page.js
screen.json
route.css
8
In the App Router, what does each folder inside the app directory usually represent?
9 Which command commonly starts a Next.js development server?
npm run export
npm run build
npm run lint
npm run dev
10 What usually happens when a developer saves a file while the Next.js development server is running?
11 What determines a URL path in Next.js file-based routing?
12
Which file path creates the /about route with the App Router?
components/routes/about/index.js, followed by manual registration in a central router
public/about/page.js
app/page/about.js
app/about/page.js
13
Which folder name defines a dynamic id route segment?
{id}
<id>
[id]
(id)
14
What can the route app/products/[id]/page.js match?
/products/42
/products/42/details/reviews without any additional route segments
/products only
/42/products
15
Which folder structure creates the nested route /dashboard/settings?
app/dashboard/settings/page.js
app/dashboard/page/settings/layout.js, with the final segment stored inside the layout file
public/dashboard/settings.js
app/settings/dashboard/page.js
16 What is a layout mainly used for in the Next.js App Router?
17 Which file defines a layout in the App Router?
wrapper.json
template.css
shared-page.config.js
layout.js
18 Which Next.js component is commonly used for client-side navigation between pages?
Image
Metadata, which creates navigation links and automatically handles every route transition
Script
Link
19 Which special file displays a loading state for a route segment?
loading.js
spinner.js
pending.js
wait.config.js
20 Which special file provides an error boundary UI for a route segment?
failure.js
exception-handler.config.js, which must manually register all possible browser and server errors
error.js
warning.js
21 A team wants to build a React application with server rendering, routing, and production build optimization without configuring each capability separately. Why is Next.js suitable for this project?
22 A product page must display current inventory when requested while keeping most rendering work on the server. Which Next.js capability best supports this requirement?
23 In an App Router project, which structure creates a home page and a shared root layout?
app/index.js and app/template.js
src/index.js and src/wrapper.js
pages/page.js and pages/layout.js
app/page.js and app/layout.js
24
A component under the app directory uses useState and handles a button click. What must be added to the component file?
metadata object
"use client" directive
"use server" directive
runtime constant
25
After creating a Next.js project, a developer runs npm run dev and edits app/page.js. What behavior should normally occur?
npm start
26
A developer creates app/contact/page.js. Which URL renders that page?
/page/contact
/contact
/app/contact
/contact/page
27
A store needs product URLs such as /products/42 and /products/105. Which file path should define the product page?
app/products/[id]/page.js
app/[products]/id/page.js
app/products/{id}/page.js
app/products/id/[page].js
28
Given app/blog/[slug]/page.js, which value should params.slug contain when a user visits /blog/next-routing?
next-routing
slug
blog
/blog/next-routing
29
A documentation site must match /docs/setup as well as /docs/setup/windows. Which route definition captures one or more segments after /docs?
app/docs/[...parts]/page.js
app/docs/(...parts)/page.js
app/docs/[[parts]]/page.js
app/docs/[parts]/page.js
30
A dashboard needs a settings page at /dashboard/settings. Which directory structure maps directly to that URL?
app/dashboard/[settings]/page.js
app/dashboard/page/settings.js
app/dashboard/settings/page.js
app/settings/dashboard/page.js
31
A team places an admin page at app/(internal)/admin/page.js. What URL should expose the page?
/admin
/(internal)/admin
/app/admin
/internal/admin
32
A navigation sidebar should persist while users move between /dashboard/reports and /dashboard/settings. Where should the sidebar usually be defined?
app/layout/dashboard.js
app/dashboard/page.js
app/dashboard/loading.js
app/dashboard/layout.js
33 What must a root layout component include so that route content can appear inside its shared HTML structure?
router prop rendered in the main element
params prop rendered in the head
children prop rendered in the body
pages prop rendered in the footer
34
A header links to /dashboard and should use client-side navigation with Next.js prefetching support. Which implementation is most appropriate?
<button href="/dashboard">Dashboard</button>
<Nav path="/dashboard">Dashboard</Nav>
<Link href="/dashboard">Dashboard</Link>
<a route="/dashboard">Dashboard</a>
35
A Client Component must redirect to /checkout only after a form is successfully submitted. Which App Router API is appropriate?
usePathname().push("/checkout")
useSearchParams().push("/checkout")
useParams().push("/checkout")
useRouter().push("/checkout")
36 A Client Component highlights a menu item when its URL matches the current route. Which hook should it use to read the current pathname?
usePathname
useRouter
useSearchParams
useParams
37 A route segment performs slow data fetching. Which file provides an immediate fallback while that segment's content is loading?
status.js
loading.js
pending.js
fallback.js
38 A dashboard route needs to catch rendering errors in its segment and offer a retry button. Which setup is appropriate?
app/dashboard/error.js as a Client Component and call reset()
app/dashboard/page.js as a Server Component and call recover()
app/dashboard/loading.js as a Server Component and call retry()
app/dashboard/layout.js as a Client Component and call reload()
39 A component is reused by several routes but should not create a URL of its own. Where can it be placed within an App Router project?
app/_components
app/[components]
app/components/page.js
app/components/loading.js
40 A page displays an image whose dimensions vary across devices, and the team wants built-in resizing and lazy loading. Which Next.js feature should be used?
Head component from next/head
Script component from next/script
Image component from next/image
Link component from next/link
41 A team is migrating a React single-page application to Next.js. One page must read directly from a database, keep credentials off the browser bundle, and send rendered HTML without creating a separate REST endpoint. Which Next.js design best satisfies these requirements?
useEffect
NEXT_PUBLIC_ environment variable
42 An App Router page contains a large data-access library and a small interactive counter. Which component boundary most effectively minimizes client-side JavaScript while preserving interactivity?
43
A project uses src/app/page.tsx, src/components/Nav.tsx, and public/logo.svg. Which reference correctly renders the logo regardless of the source file's depth?
<img src="/logo.svg" alt="Logo" />
<img src="/public/logo.svg" alt="Logo" />
<img src="../public/logo.svg" alt="Logo" />
<img src="src/public/logo.svg" alt="Logo" />
44
A repository accidentally contains both app/page.tsx and src/app/page.tsx, while configuration files remain at the repository root. What is the correct architectural conclusion?
src/app available under /src
src/app taking precedence on conflicts
app supplies layouts while src/app supplies pages
45 A Server Component needs to render an interactive search box that uses state and browser event handlers. Which composition is valid under the App Router?
"use client"
useState directly to the Server Component without a directive
"use server" to the search box before calling useState
46
A developer adds "use client" to app/dashboard/layout.tsx and imports several utility modules from it. What is the most important consequence?
47
During next dev, editing a component sometimes preserves its local state and sometimes remounts it. Which statement best describes the expected behavior?
48
A route works under next dev but fails only when preparing a production deployment. Which command sequence most directly tests the production compilation and runtime behavior locally?
next build followed by next start
next start followed by next build
next lint followed by next dev
next dev followed by next export
49
Given app/page.tsx, app/about/page.tsx, app/about/team.tsx, and app/contact/layout.tsx, which URL set is directly routable from these files?
/, /about, and /about/team
/about/team and /contact
/ and /about
/, /about, and /contact
50
A project contains app/(marketing)/about/page.tsx. What public URL is produced, assuming no conflicting route exists?
/marketing/about
/about
/about/marketing
/(marketing)/about
51
A segment contains both app/blog/[slug]/page.tsx and app/blog/archive/page.tsx. Which component handles a request for /blog/archive?
archive page because static segments have precedence
[slug] page with slug equal to archive
52
For a route defined as app/docs/[[...parts]]/page.tsx, which request can match with parts absent rather than containing one or more strings?
/docs/api
/docs/api/auth
/docs/api/auth/login
/docs
53
A developer wants /shop to show the shop index while /shop/a/b captures a and b in one route parameter. Which route structure supports both without a separate /shop page?
app/shop/[[...slug]]/page.tsx
app/shop/[slug]/page.tsx
app/[shop]/[...slug]/page.tsx
app/shop/[...slug]/page.tsx
54
Given app/dashboard/settings/profile/page.tsx, which directories may define layouts that naturally wrap the profile page without changing its URL?
app and app/dashboard/settings/profile
app, dashboard, settings, and profile segments
app/dashboard and app/dashboard/settings
page.tsx
55
Two teams create app/(store)/products/page.tsx and app/(catalog)/products/page.tsx. Why is this structure invalid?
products segment must be dynamic inside a route group
app
/products
56
A shared dashboard layout fetches user data and renders a sidebar. When navigating between /dashboard/analytics and /dashboard/settings with Next.js navigation, which behavior should the developer design for?
57
An App Router application defines its required root layout in app/layout.tsx. Which output is the root layout responsible for providing?
<main> element and a route-specific <head> element
<html> and <body> elements around its children
<div id="root"> element and a hydration script
<template> element and a client-side router outlet
58
A Client Component handles a successful form interaction and must navigate programmatically to /account without a full document reload. Which API is appropriate?
useRouter from next/router, followed by router.reload("/account")
window.location.replace("/account") as the standard router API
redirect inside the click handler after marking it async
useRouter from next/navigation, followed by router.push("/account")
59
A page renders <Link href="/reports">Reports</Link>, but /reports has a slow server-rendered subtree. Which statement best captures why navigation may still feel faster than using a plain <a> element?
Link stores the destination's database records in browser local storage
Link converts every destination into a fully static HTML document
Link bypasses all server rendering after the first application request
Link may prefetch route data and performs client-side transitions
60
A route segment contains page.tsx, loading.tsx, and error.tsx. The page suspends while fetching and later throws during rendering. Which behavior matches the App Router's segment boundaries?
loading.tsx handles both pending work and thrown rendering errors permanently
error.tsx renders first, then loading.tsx replaces it after the failure
loading.tsx can provide fallback UI, then error.tsx can handle the failure
error.tsx is ignored whenever the same segment also defines loading.tsx
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →