Next Js Flashcards

(25 cards)

1
Q

What is the App Router in Next.js?

A

A newer, React Server Components–first routing model with nested layouts and server-first rendering

It coexists with the legacy Pages Router model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does File-Based Routing entail in Next.js?

A

Routes are created by folder/file structure; e.g., /app/dashboard/page.tsx becomes /dashboard

In App Router, route segments are folders, and page.tsx is the entry point for that segment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are Layouts in Next.js?

A

Wrap pages and persist across navigation; server components by default

Central to shared UI and data loading patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of Route Groups in Next.js?

A

Organize routes without affecting the URL path

Helps share layouts or group related routes while keeping clean URLs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do Dynamic Routes use in their structure?

A

Bracket segments (e.g., /app/posts/[id]/page.tsx) to capture path params

Enables server-side data fetching per request or cached entry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between Catch-All and Optional Catch-All routes?

A
  • Catch-All: Captures multiple segments
  • Optional Catch-All: Matches parent route with no segments

Routing resolution is server-side and happens before rendering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In the App Router, what is the default model for components?

A

Server components by default

They render on the server and can access server-only resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ‘use client’ indicate in a Next.js file?

A

The file runs in the browser and can use hooks like useState and useEffect

Client components create a boundary for client-bundled imports.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are Server Actions in Next.js?

A

Let you call server-side functions from forms or client components without creating an API route

Execution occurs on the server, handling serialization and request wiring.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does fetch() work in server components?

A

Can be automatically memoized and cached based on request and cache directives

This reduces client bundle size and improves performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of Caching and Revalidation in Next.js?

A

Caches fetched data and rendered output; allows for revalidation windows or on-demand invalidation

Primarily a server concern affecting response recomputation frequency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the function of revalidatePath / revalidateTag?

A

Invalidate cached routes or tagged fetches after mutations

Enables patterns for updating content and refreshing cached views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does Streaming and Suspense improve in server rendering?

A

Improves time-to-first-byte and perceived performance by streaming HTML chunks

Suspense boundaries define what can stream early vs what waits for data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the role of loading.tsx in Next.js?

A

Provides a Suspense fallback during navigation or server rendering

Rendered while the server produces the segment’s payload.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does error.tsx handle?

A

Acts as a client component error boundary for a route segment

Displays recoverable UI when rendering fails, often with server-side logs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does not-found.tsx render?

A

Renders when notFound() is invoked or a route can’t be resolved

The decision is typically server-side.

17
Q

What do route.ts files define?

A

HTTP endpoints (GET/POST/etc.) within the App Router

They run on the server or edge, replacing traditional API routes.

18
Q

What is the function of middleware.ts?

A

Runs before a request is completed; can rewrite, redirect, set headers, or enforce auth

Ideal for lightweight request-level logic.

19
Q

What does next/navigation provide?

A

Handles navigation in App Router with useRouter, usePathname, and redirect()

Hook-based navigation is client-side; redirect() can be server-side.

20
Q

What does the <link></link> component enable?

A

Client-side navigation and prefetching route data in the background

Rendering occurs client-side on interaction.

21
Q

What does the Metadata API generate?

A

<title>, Open Graph tags, and other head metadata per route

## Footnote

This is server-side computation integrated into the rendering pipeline.
</title>

22
Q

What does next/image do?

A

Serves responsive images, lazy loads by default, and optimizes formats and sizes

Optimization happens server-side or via an external loader.

23
Q

What is the purpose of next/font?

A

Loads and subsets fonts with automatic CSS injection and improved performance

Reduces layout shift and is largely build/server-managed.

24
Q

What is the distinction between server-only and public-prefixed Environment Variables?

A

Variables without a public prefix are server-only; public-prefixed variables are exposed to the client bundle

This boundary keeps secrets out of the browser.

25
How does the App Router express **Rendering Modes**?
Via caching and revalidation controls rather than separate functions ## Footnote Execution is server-side, with outputs computed per request or cached.