React / Next.js

Next.js Fundamentals

App Router, Server Components, Client Components, file-based routing, layouts, pages

25 interview questionsยท
Mid-Level
1

What is the App Router in Next.js?

Answer

The App Router is the new routing system in Next.js 13+ based on the app/ directory. It replaces the Pages Router and introduces Server Components by default, shared layouts, and a more flexible routing model with file conventions like page.tsx, layout.tsx and loading.tsx.

2

How to create an /about route in the App Router?

Answer

In the App Router, each folder represents a route segment. To create /about, create app/about/page.tsx. The page.tsx file is required to make a route publicly accessible. Without this file, the folder will only be a path segment without a displayed page.

3

What is the default behavior of components in the App Router?

Answer

In the App Router, all components are Server Components by default. They execute only on the server and send no JavaScript to the client, improving performance. To use client features (hooks, events), you must add the 'use client' directive at the top of the file.

4

How to create a dynamic route /posts/[id] in the App Router?

5

What is the purpose of the layout.tsx file in the App Router?

+22 interview questions

Master React / Next.js for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free