Next.js What Is Next.js?
Next.js is a React framework. React draws the page, and Next.js adds the parts around it.
Check the Next.js version
The version command prints the installed Next.js number. This course uses 16.4.6.
npx next --versionThe smallest Next.js page
A page is a React component with a default export. The file name sets the web address.
export default function Home() {
return <h1>My Bookshelf</h1>;
}Example
const parts = ["React draws the page", "routing", "server rendering", "deployment"];
console.log("Next.js is React plus:");
parts.forEach((part) => console.log("- " + part));Key points
- Framework: a ready-made set of tools that fills in the missing parts of a job
- React draws the page. It turns components into what the reader sees.
- Next.js adds routing. Routing is the map from a web address to a page.
- Next.js adds server rendering. The server builds the page before it reaches the reader.
- Next.js adds deployment. Deployment is putting the finished app on the web.
In this example, the list holds the four parts of Next.js. The first part is React, which draws the page. The other three parts are what the framework adds. Routing maps a web address to a page. Server rendering builds the page on the server. Deployment puts the app on the web. React plus those three parts is Next.js.
Note
Next.js is built on React. Every React component you know still works in Next.js.
Try it Yourself
Edit the code, then press Run.
Running is simulated Β· TypeScript Playground
Exercise
What does Next.js add to React?