
Once you know the App Router basics, the next interview questions are about how a Next.js app really fetches, caches and renders data. This set covers static and dynamic rendering, incremental static regeneration (ISR), on-demand revalidation, Server Actions, special files, metadata for SEO and middleware.
How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 15 questions.
Topics covered in this set
- Static vs dynamic rendering in the App Router
- generateStaticParams and incremental static regeneration
- fetch caching, revalidatePath and revalidateTag
- Server Actions and Route Handlers
- Special files: loading, error and not-found
- generateMetadata, next/image and middleware
Next.js MCQs with answers and explanations
Q1. In the App Router, which function lets you pre-render dynamic route segments such as /blog/[slug] at build time?
a) generateMetadata
b) getStaticPaths
c) generateStaticParams
d) getServerSideProps
Q2. What does the following export in app/blog/page.tsx do?
export const revalidate = 60;
export default async function BlogPage() {
const posts = await getPosts();
return <PostList posts={posts} />;
}
a) Caches the page and regenerates it in the background at most once every 60 seconds when it is requested
b) Forces the page to render on every request
c) Delays the response by 60 seconds
d) Rebuilds the whole site every 60 seconds
Q3. In Next.js 15, how are fetch requests inside Server Components cached by default?
a) They are cached for exactly 60 seconds
b) They are cached only in the browser
c) They are cached forever
d) They are not cached by default unless you opt in, for example with cache: 'force-cache'
Q4. After a user submits a form that adds a new blog post, which function can you call to purge cached data for the /blog route?
a) router.refresh() on the server
b) revalidatePath('/blog')
c) useEffect
d) generateStaticParams
Q5. How do you attach a cache tag to a fetch request so it can be revalidated later with revalidateTag('posts')?
a) fetch(url, { tag: 'posts' })
b) fetch(url, { next: { tags: ['posts'] } })
c) fetch(url, { cache: 'posts' })
d) fetch(url).tag('posts')
Q6. Using cookies() or headers() inside a Server Component usually makes the route:
a) Fail during the build
b) Run only on the client
c) Statically rendered at build time
d) Dynamically rendered at request time
Q7. Which directive marks a function as a Server Action that can be called from a form or a Client Component?
a) 'use server'
b) 'use action'
c) 'use strict'
d) 'use client'
Q8. What is a loading.tsx file in a route segment used for?
a) Defining API routes
b) Preloading images
c) Showing an instant loading UI, wrapped in a Suspense boundary, while the segment's content streams in
d) Loading environment variables
Q9. Why must an error.tsx file be a Client Component?
a) Because Server Components cannot render text
b) It does not need to be
c) Because errors cannot happen on the server
d) Because it is built on a React error boundary and receives a reset function to retry rendering
Q10. Which file creates an API endpoint inside the app directory?
a) route.ts
b) handler.ts
c) server.ts
d) api.ts
Q11. getServerSideProps belongs to which part of Next.js?
a) next.config.js
b) The App Router
c) The Pages Router
d) Middleware
Q12. What is generateMetadata mainly used for?
a) Generating TypeScript types
b) Creating dynamic SEO metadata such as title, description and Open Graph tags based on route params or fetched data
c) Generating sitemaps automatically
d) Creating static params
Q13. Which of these is NOT a built-in benefit of the next/image component?
a) Automatically writing alt text for the image
b) Lazy loading by default
c) Serving resized images in modern formats such as WebP
d) Avoiding layout shift by reserving space
Q14. What is middleware (renamed to proxy in Next.js 16) commonly used for?
a) Bundling CSS
b) Replacing the database layer
c) Rendering React components
d) Running logic such as auth checks, redirects, rewrites or setting headers before a request reaches a route
Q15. What happens when you call notFound() from next/navigation in a Server Component?
a) The page silently renders nothing
b) The app crashes
c) Rendering stops and the nearest not-found.tsx UI is shown with a 404 status
d) The user is redirected to the home page
Quick revision notes
- generateStaticParams pre-renders dynamic segments; export const revalidate enables ISR.
- Next.js 15 does not cache fetch by default. Turn it on with cache: 'force-cache' or the revalidate options.
- revalidatePath clears a route and revalidateTag clears tagged data on demand, usually after a Server Action.
- cookies(), headers() and searchParams make a route dynamic.
- Special files: loading.tsx (Suspense fallback), error.tsx (client error boundary), not-found.tsx (404).
- Use generateMetadata for SEO on dynamic pages, and always give next/image a meaningful alt.
Frequently asked questions
What is the difference between ISR and SSR in Next.js?
SSR renders the page on every request. ISR serves a cached static page and rebuilds it in the background after a set time or when you ask. So you get almost static speed with fairly fresh data.
When should I use revalidateTag instead of revalidatePath?
Use revalidateTag when the same data shows up on many pages, like a product on both the listing and the detail page. One tag clears every cached request that uses it, on whichever page it appears.
Are Server Actions secure?
They run on the server, but anyone can still call them like a public endpoint. So check authentication and validate input inside every Server Action, the same way you would in an API route.
Comments
Post a Comment