Sample questions
Question 1Easy
What does a route.ts file in an App Router folder define?
- The React component used as the page UI for that segment
- The redirect rules applied to every page in the whole application
- A route handler that answers HTTP requests such as GET or POST
- A list of static paths that should be generated at build time
Answer: C. A route handler that answers HTTP requests such as GET or POST
Explanation
Route handlers export functions named after HTTP methods (GET, POST, ...) that take a Request and return a Response.
Step-by-step solution
- A route.ts file in an App Router folder defines a route handler.
- It exports functions named after HTTP methods, such as GET and POST.
- Each function takes a Request and returns a Response (option C).
Why the other options are wrong
- A. A page component is defined in page.tsx, not route.ts.
- B. Redirect rules are not defined per route.ts file for every page.
- D. Static path lists are generated by a separate function, not route.ts.
Tip: Use route.ts for API endpoints and page.tsx for UI.
Question 2Easy
How do you create the URL path /blog/[slug] in the App Router?
- Add the path to an array in a routes.json configuration file
- Create the folder app/blog/[slug]/ containing page.tsx
- Create the file app/blog-slug.tsx at the project root
- Create pages/blog.tsx and read the slug from window.location
Answer: B. Create the folder app/blog/[slug]/ containing page.tsx
Explanation
Folders define URL segments; square brackets make a dynamic segment whose value is passed to the page as a param.
Step-by-step solution
- In the App Router, folders define URL segments.
- A folder name in square brackets is a dynamic segment.
- A page.tsx file inside app/blog/ with a slug folder gives the path /blog/[slug] (option B).
Why the other options are wrong
- A. The App Router does not use a routes.json file to list paths.
- C. A single root file does not create a nested dynamic route.
- D. Pages/blog.tsx is the older Pages Router, not the App Router.
Tip: Folder structure is the routing: each folder is a path segment.
Question 3Easy
By default, components in the Next.js App Router are:
- Server Components
- Static HTML with no React
- Web Components
- Client Components
Answer: A. Server Components
Explanation
App Router components are Server Components unless a module is marked with "use client".
Step-by-step solution
- Components in the App Router are Server Components unless marked otherwise.
- A module needs the use client directive to become a Client Component.
- So the default is Server Components (option A).
Why the other options are wrong
- B. Components are rendered by React, not left as static HTML without React.
- C. Web Components are a separate browser standard.
- D. Client Components need the use client directive, so they are not the default.
Tip: Add use client only to the components that need state, effects or event handlers.
Question 4Easy
In the Next.js App Router, which file defines the UI for a route segment?
- route.config.ts
- index.tsx
- page.tsx
- view.tsx
Answer: C. page.tsx
Explanation
A route segment becomes publicly accessible when its folder contains a page file.
Step-by-step solution
- In the App Router, a route segment is public when its folder has a page file.
- The page file holds the UI for that segment.
- So page.tsx defines the UI for the segment (option C).
Why the other options are wrong
- A. route.config.ts is not an App Router file for UI.
- B. index.tsx is not a special App Router file.
- D. view.tsx is not a special App Router file.
Tip: Use page.tsx for the page UI and route.ts for API handlers, each in its own route folder.
Question 5Medium
Can the same folder contain both page.tsx and route.ts?
- Yes, route.ts always takes priority over page.tsx
- No, they conflict because both would handle the same path
- Yes, page.tsx handles GET and route.ts handles POST
- No, route.ts may only appear in the root app/ folder itself
Answer: B. No, they conflict because both would handle the same path
Explanation
A route segment is either a page or a route handler; having both at the same level is a conflict.
Step-by-step solution
- Both page and route handle a path.
- They conflict.
- Next.js does not allow both in one folder.
Why the other options are wrong
- A. No priority exists.
- C. They cannot be split by method.
- D. route.ts can be nested.
Tip: One owner per path.
Question 6Medium
What is a route group, such as a folder named (marketing)?
- A folder whose routes are only visible to logged-in users
- A dynamic segment that matches any number of path parts
- A folder that organises routes without adding a URL segment
- A folder that is excluded from the production build entirely
Answer: C. A folder that organises routes without adding a URL segment
Explanation
Parentheses make the folder purely organisational: app/(marketing)/about/page.tsx is served at /about.
Step-by-step solution
- Wrapping a folder name in parentheses makes a route group.
- It organises routes and layouts.
- It does not change the URL.
Why the other options are wrong
- A. It is not an auth mechanism.
- B. That is a catch-all segment.
- D. The routes are built normally.
Tip: (folder) = no URL segment.
Question 7Medium
In the App Router, which pattern matches /shop, /shop/a and /shop/a/b with one page?
- app/shop/[[...slug]]/page.tsx
- app/shop/(...slug)/page.tsx
- app/shop/[slug]/page.tsx
- app/shop/[...slug]/page.tsx
Answer: A. app/shop/[[...slug]]/page.tsx
Explanation
Double brackets make an optional catch-all that also matches the base path; [...slug] alone does not match /shop.
Step-by-step solution
- A folder with double square brackets around ...slug is an optional catch-all segment.
- It matches the base path /shop as well as /shop/a and /shop/a/b.
- A single catch-all in one bracket pair does not match /shop itself (option A).
Why the other options are wrong
- B. Parentheses make a route group that does not add a segment, and it is not a catch-all.
- C. A single dynamic segment matches only one level, such as /shop/a.
- D. A catch-all without the double brackets does not match the bare /shop path.
Tip: Use double square brackets around ...name when the base path should also match.
Question 8Medium
Why must error.tsx in the App Router be a Client Component?
- Error boundaries need client-side state and a reset handler
- error.tsx is only shown during development and not in production
- Next.js requires every special file to be a Client Component
- Server Components are not allowed to throw any errors at all
Answer: A. Error boundaries need client-side state and a reset handler
Explanation
error.tsx is implemented as a React error boundary, which needs client-side behaviour such as a retry (reset) function.
Step-by-step solution
- error.tsx is implemented as a React error boundary.
- Error boundaries need client-side state and a reset function, so they run in the browser.
- So error.tsx must be a Client Component (option A).
Why the other options are wrong
- B. error.tsx shows in production too.
- C. Only error.tsx needs the client behaviour, not every special file.
- D. Server Components can throw errors; error.tsx catches them on the client.
Tip: Mark error.tsx with use client and use its reset function to retry.
Question 9Hard
A component uses useState and is placed in a layout that is a Server Component. What must happen?
- useState must be replaced by a global variable
- The stateful component must be marked "use client"
- The layout must be converted to an async function
- The layout must be moved into a route.ts handler file
Answer: B. The stateful component must be marked "use client"
Explanation
Hooks like useState only work in Client Components; the layout can stay a Server Component and render the client child.
Step-by-step solution
- UseState only works in Client Components.
- A Server Component layout cannot hold state itself.
- Marking the stateful component with use client lets the layout stay a Server Component (option B).
Why the other options are wrong
- A. A global variable would be shared across users and does not replace state.
- C. Making the layout async does not enable useState.
- D. A route.ts handler does not render layouts.
Tip: Keep layouts as Server Components and move only the stateful part into a Client Component.
Question 10Hard
Why is it recommended to push "use client" as far down the tree as possible?
- Client Components cannot be nested more than one level deep inside a layout
- Server Components lower in the tree cannot receive any props from parents
- Everything imported under the boundary ships to the browser as JS
- A high boundary disables routing and makes every link do a full reload
Answer: C. Everything imported under the boundary ships to the browser as JS
Explanation
A "use client" module pulls its imports into the client bundle. Keeping only interactive leaves as Client Components keeps the rest server-only.
Step-by-step solution
- Everything imported by a Client Component is bundled.
- A high boundary ships more JS.
- Push it down to keep bundles small.
Why the other options are wrong
- A. Nesting is allowed.
- B. Props can be passed.
- D. Routing is unaffected.
Tip: Small client islands.
Practise all 15 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →