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>
<Form>
<Script>
<Head>
5 Which directory commonly contains routes when using the Next.js App Router?
public
node_modules, which contains all route definitions written by the developer
app
styles
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?
screen.json
route.css
page.js
component.config.js, which registers every component used across the application
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 lint
npm run dev
npm run build
npm run export
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
app/page/about.js
public/about/page.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/details/reviews without any additional route segments
/42/products
/products/42
/products only
15
Which folder structure creates the nested route /dashboard/settings?
app/dashboard/settings/page.js
app/settings/dashboard/page.js
public/dashboard/settings.js
app/dashboard/page/settings/layout.js, with the final segment stored inside the layout file
16 What is a layout mainly used for in the Next.js App Router?
17 Which file defines a layout in the App Router?
layout.js
wrapper.json
shared-page.config.js
template.css
18 Which Next.js component is commonly used for client-side navigation between pages?
Link
Script
Metadata, which creates navigation links and automatically handles every route transition
Image
19 Which special file displays a loading state for a route segment?
loading.js
wait.config.js
pending.js
spinner.js
20 Which special file provides an error boundary UI for a route segment?
exception-handler.config.js, which must manually register all possible browser and server errors
error.js
warning.js
failure.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?
src/index.js and src/wrapper.js
app/page.js and app/layout.js
pages/page.js and pages/layout.js
app/index.js and app/template.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?
/app/contact
/contact
/page/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?
blog
next-routing
slug
/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/settings/page.js
app/dashboard/page/settings.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?
/app/admin
/internal/admin
/(internal)/admin
/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/layout.js
app/dashboard/loading.js
33 What must a root layout component include so that route content can appear inside its shared HTML structure?
children prop rendered in the body
params prop rendered in the head
router prop rendered in the main element
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?
<a route="/dashboard">Dashboard</a>
<button href="/dashboard">Dashboard</button>
<Nav path="/dashboard">Dashboard</Nav>
<Link href="/dashboard">Dashboard</Link>
35
A Client Component must redirect to /checkout only after a form is successfully submitted. Which App Router API is appropriate?
useRouter().push("/checkout")
usePathname().push("/checkout")
useSearchParams().push("/checkout")
useParams().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?
useParams
useRouter
useSearchParams
usePathname
37 A route segment performs slow data fetching. Which file provides an immediate fallback while that segment's content is loading?
fallback.js
pending.js
loading.js
status.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/loading.js as a Server Component and call retry()
app/dashboard/layout.js as a Client Component and call reload()
app/dashboard/page.js as a Server Component and call recover()
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/loading.js
app/components/page.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
Link component from next/link
Image component from next/image
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="/public/logo.svg" alt="Logo" />
<img src="../public/logo.svg" alt="Logo" />
<img src="src/public/logo.svg" alt="Logo" />
<img src="/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?
app supplies layouts while src/app supplies pages
src/app available under /src
src/app taking precedence on conflicts
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 dev followed by next export
next build followed by next start
next lint followed by next dev
next start followed by next build
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?
/ and /about
/, /about, and /about/team
/, /about, and /contact
/about/team and /contact
50
A project contains app/(marketing)/about/page.tsx. What public URL is produced, assuming no conflicting route exists?
/about
/(marketing)/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
/docs/api/auth/login
/docs/api/auth
/docs/api
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?
page.tsx
app/dashboard and app/dashboard/settings
app and app/dashboard/settings/profile
app, dashboard, settings, and profile segments
55
Two teams create app/(store)/products/page.tsx and app/(catalog)/products/page.tsx. Why is this structure invalid?
app
/products
products segment must be dynamic inside a route group
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?
<html> and <body> elements around its children
<div id="root"> element and a hydration script
<template> element and a client-side router outlet
<main> element and a route-specific <head> element
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")
useRouter from next/navigation, followed by router.push("/account")
redirect inside the click handler after marking it async
window.location.replace("/account") as the standard router API
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 converts every destination into a fully static HTML document
Link may prefetch route data and performs client-side transitions
Link bypasses all server rendering after the first application request
Link stores the destination's database records in browser local storage
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?
error.tsx is ignored whenever the same segment also defines loading.tsx
loading.tsx can provide fallback UI, then error.tsx can handle the failure
error.tsx renders first, then loading.tsx replaces it after the failure
loading.tsx handles both pending work and thrown rendering errors permanently
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 →