LearnThatStack Ace your next interview
Frontend Development

Next.js.

Start free Change topic Change
Practice · Questions

All questions

Showing of 94
Beginner 28
01

What are the main benefits of using Next.js over Create React App?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • SEO Optimization: Server-side rendering provides better search engine optimization
  • Performance: Automatic code splitting and optimization
  • Routing: Built-in file-based routing system
  • API Routes: Can create backend endpoints within the same project
  • Image Optimization: Built-in image optimization with the Image component
  • Developer Experience: Hot reloading, TypeScript support, and better error messages
  • Production Ready: Optimized builds with minimal configuration
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

Explain the file-based routing system in Next.js

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Next.js uses a file-based routing system where the file structure in the pages directory (or app directory in App Router) automatically creates routes:

pages/
  index.js       → /
  about.js       → /about
  contact.js     → /contact
  blog/
    index.js     → /blog
    [slug].js    → /blog/:slug

Each file exports a React component as the default export, which becomes the page component for that route.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is the purpose of the `_app.js` file?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The _app.js file is a custom App component that wraps all page components. It's used to:

  • Keep state when navigating between pages
  • Add global CSS
  • Inject additional data into pages
  • Handle global error boundaries
  • Add common layout components
function MyApp({ Component, pageProps }) {
  return (
    <div>
      <GlobalHeader />
      <Component {...pageProps} />
      <GlobalFooter />
    </div>
  );
}

export default MyApp;
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

How do you add global CSS in Next.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Global CSS can only be imported in _app.js:

// pages/_app.js
import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}

export default MyApp;
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What are CSS Modules and how do you use them in Next.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

CSS Modules allow you to write component-scoped CSS by creating files with .module.css extension:

/* Button.module.css */
.primary {
  background-color: blue;
  color: white;
}
// Button.js
import styles from './Button.module.css';

function Button() {
  return <button className={styles.primary}>Click me</button>;
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is the `public` directory used for?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The public directory serves static assets directly from the root URL. Files in this directory can be accessed without any path prefix:

public/
  favicon.ico     → /favicon.ico
  logo.png        → /logo.png
  images/
    hero.jpg      → /images/hero.jpg
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

How do you implement dynamic routing in Next.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Dynamic routes are created using square brackets in the filename:

pages/
  posts/
    [id].js       → /posts/:id
    [...slug].js  → /posts/* (catch-all)
// pages/posts/[id].js
import { useRouter } from 'next/router';

function Post() {
  const router = useRouter();
  const { id } = router.query;
  
  return <h1>Post: {id}</h1>;
}

export default Post;
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What is the difference between `Link` and `router.push()`?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • Link: Declarative navigation component for client-side transitions
  • router.push(): Programmatic navigation method
import Link from 'next/link';
import { useRouter } from 'next/router';

function Navigation() {
  const router = useRouter();
  
  const handleClick = () => {
    router.push('/about');
  };
  
  return (
    <div>
      <Link href="/about">About Page</Link>
      <button onClick={handleClick}>Go to About</button>
    </div>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

What is `getStaticProps` and when should you use it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

getStaticProps fetches data at build time for static generation:

export async function getStaticProps() {
  const res = await fetch('https://api.example.com/posts');
  const posts = await res.json();
  
  return {
    props: {
      posts,
    },
    revalidate: 3600, // ISR: revalidate every hour
  };
}

function Blog({ posts }) {
  return (
    <div>
      {posts.map(post => (
        <article key={post.id}>{post.title}</article>
      ))}
    </div>
  );
}

Use when: Content is static or changes infrequently, for better performance and SEO.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

What is `getServerSideProps` and when should you use it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

getServerSideProps fetches data on each request at runtime:

export async function getServerSideProps(context) {
  const { req, res, params, query } = context;
  
  const data = await fetch(`https://api.example.com/user/${params.id}`);
  const user = await data.json();
  
  return {
    props: {
      user,
    },
  };
}

Use when: Data changes frequently, requires authentication, or needs request-specific information.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

How do you fetch data on the client-side in Next.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use standard React patterns like useEffect or data fetching libraries:

import { useState, useEffect } from 'react';

function Profile() {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    fetch('/api/user')
      .then(res => res.json())
      .then(data => {
        setUser(data);
        setLoading(false);
      });
  }, []);
  
  if (loading) return <div>Loading...</div>;
  
  return <div>Welcome, {user.name}!</div>;
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

12

How do you create Client Components in App Router?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use the 'use client' directive at the top of the file:

'use client';

import { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);
  
  return (
    <button onClick={() => setCount(count + 1)}>
      Count: {count}
    </button>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

13

How do loading states work in App Router?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Create a loading.js file to show loading UI while the page loads:

// app/posts/loading.js
export default function Loading() {
  return <div>Loading posts...</div>;
}

// app/posts/page.js
async function PostsPage() {
  // This delay will show the loading component
  await new Promise(resolve => setTimeout(resolve, 2000));
  const posts = await fetch('/api/posts');
  
  return <PostsList posts={posts} />;
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

14

How do you create API routes in Next.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Create files in the pages/api/ directory (Pages Router) or app/api/ directory (App Router):

Pages Router:

// pages/api/users.js
export default function handler(req, res) {
  if (req.method === 'GET') {
    res.status(200).json({ users: [] });
  } else {
    res.setHeader('Allow', ['GET']);
    res.status(405).end(`Method ${req.method} Not Allowed`);
  }
}

App Router:

// app/api/users/route.js
export async function GET() {
  return Response.json({ users: [] });
}

export async function POST(request) {
  const data = await request.json();
  // Process data
  return Response.json({ success: true });
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

15

How do you handle different HTTP methods in API routes?

Part of Pro
16

How do you access request data in API routes?

Part of Pro
17

How do you optimize images in Next.js?

Part of Pro
18

What are the benefits of the Next.js Image component?

Part of Pro
19

What is the purpose of `next.config.js`?

Part of Pro
20

What styling options are available in Next.js?

Part of Pro
21

How do you use Sass/SCSS in Next.js?

Part of Pro
22

How do you implement styled-jsx in Next.js?

Part of Pro
23

How do you integrate Tailwind CSS with Next.js?

Part of Pro
24

How do you deploy a Next.js application to Vercel?

Part of Pro
25

How do you build a Next.js application for production?

Part of Pro
26

How do you configure environment variables in Next.js?

Part of Pro
27

How do you create custom error pages in Next.js?

Part of Pro
28

How do you set up TypeScript in Next.js?

Part of Pro
Intermediate 41
29

What is the difference between `_app.js` and `_document.js`?

Part of Pro
30

How do you pass data between pages in Next.js?

Part of Pro
31

What are catch-all routes and how do you implement them?

Part of Pro
32

How does prefetching work in Next.js?

Part of Pro
33

What is `getStaticPaths` and why is it needed?

Part of Pro
34

What is the difference between `fallback: false`, `fallback: true`, and `fallback: 'blocking'`?

Part of Pro
35

What is SWR and how do you use it with Next.js?

Part of Pro
36

Explain the differences between SSR, SSG, and CSR in Next.js

Part of Pro
37

What is Incremental Static Regeneration (ISR)?

Part of Pro
38

What are the main differences between App Router and Pages Router?

Part of Pro
39

How does data fetching differ between App Router and Pages Router?

Part of Pro
40

What are Server Components and how do they work in App Router?

Part of Pro
41

What are layouts in App Router and how do you use them?

Part of Pro
42

How do you handle errors in App Router?

Part of Pro
43

How do you implement authentication in API routes?

Part of Pro
44

How do you handle file uploads in API routes?

Part of Pro
45

How does automatic code splitting work in Next.js?

Part of Pro
46

How do you implement lazy loading in Next.js?

Part of Pro
47

How do you optimize fonts in Next.js?

Part of Pro
48

How do you analyze bundle size in Next.js?

Part of Pro
49

What is the difference between `publicRuntimeConfig` and `serverRuntimeConfig`?

Part of Pro
50

How do you implement redirects and rewrites in Next.js?

Part of Pro
51

How do you generate a sitemap in Next.js?

Part of Pro
52

How do you implement authentication with NextAuth.js?

Part of Pro
53

How do you protect pages with authentication?

Part of Pro
54

How do you implement CORS in Next.js API routes?

Part of Pro
55

How do you implement error boundaries in Next.js?

Part of Pro
56

How do you handle API errors in Next.js?

Part of Pro
57

What is middleware in Next.js and how do you use it?

Part of Pro
58

How do you implement internationalization (i18n) in Next.js?

Part of Pro
59

How do you implement database connections in Next.js?

Part of Pro
60

How do you implement search functionality in Next.js?

Part of Pro
61

How do you implement custom hooks for data fetching in Next.js?

Part of Pro
62

How do you type API routes in TypeScript?

Part of Pro
63

How do you set up testing in Next.js?

Part of Pro
64

How do you test API routes in Next.js?

Part of Pro
65

How do you implement global state management in Next.js?

Part of Pro
66

How do you implement data persistence in Next.js?

Part of Pro
67

How do you create reusable components in Next.js?

Part of Pro
68

How do you integrate a headless CMS with Next.js?

Part of Pro
69

How do you implement MDX in Next.js?

Part of Pro
Expert 25
70

How do you implement hybrid rendering in Next.js?

Part of Pro
71

How do you implement rate limiting in Next.js?

Part of Pro
72

How do you implement Progressive Web App (PWA) features in Next.js?

Part of Pro
73

How do you implement real-time features with WebSockets in Next.js?

Part of Pro
74

How do you implement server-side caching in Next.js?

Part of Pro
75

How do you implement Server Actions in Next.js App Router?

Part of Pro
76

How do you optimize Core Web Vitals in Next.js?

Part of Pro
77

How do you implement A/B testing in Next.js?

Part of Pro
78

How do you implement background jobs in Next.js?

Part of Pro
79

How do you implement performance monitoring in Next.js?

Part of Pro
80

What security considerations should you keep in mind with Next.js?

Part of Pro
81

How do you implement custom server with Next.js?

Part of Pro
82

How do you implement multi-zone deployments in Next.js?

Part of Pro
83

How do you use Next.js with Edge Runtime?

Part of Pro
84

How do you analyze and optimize your Next.js bundle?

Part of Pro
85

How do you implement tree shaking in Next.js?

Part of Pro
86

How do you implement compound components in Next.js?

Part of Pro
87

How do you integrate GraphQL with Next.js?

Part of Pro
88

How do you implement the compound component pattern in Next.js?

Part of Pro
89

How do you implement render props pattern in Next.js?

Part of Pro
90

How do you implement custom webpack configuration in Next.js?

Part of Pro
91

How do you implement custom babel configuration in Next.js?

Part of Pro
92

How do you implement virtualization for large lists in Next.js?

Part of Pro
93

How do you implement infinite scrolling in Next.js?

Part of Pro
94

How do you implement advanced caching strategies in Next.js?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Next.js? Send them this set.
Pro · $10/mo

80 of 94 Next.js answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git