What is Next.js, and how does it differ from React?
Quick interview answer
Next.js is a React framework for building web applications. React handles the UI, while Next.js adds routing, server rendering, data fetching patterns, and production tooling. It lets a team build frontend pages and server endpoints in one project. I use it when I need a complete application rather than configuring every tool myself.
Detailed explanation
React is the component library. Next.js supplies conventions for routes, layouts, server execution, assets, and deployment. It does not replace React; React components still power the UI.
Code example
// app/page.tsx
export default function Home() {
return <h1>Welcome to our shop</h1>;
}React is the component library.
Real-world example
A startup can launch its storefront with routes, metadata, and server-rendered product pages in one codebase.
Common interview mistakes
Calling Next.js a replacement for React instead of a framework built on it.
Follow-up questions
- 1
When would you choose plain React with a separate backend?