Creating your first Next.js page

Now, let's create the first page and place it in the pages folder:

// pages/index.jsimport React from "react";export default () => (<div>Hello, World!</div>);

Now, if you run the dev server (npm start) and visit http://localhost:3000, you will see this page:

Now, let's see how Next.js handles errors in your files:

// pages/index.jsimport React from "react";export default () => (<div><p>Hello, World!</div>);//                          ^ here we purposely not closing this tag

Then, reload the page to see this:

Get Next.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.