How to do it...

Now that we have installed the dependencies, let's create our first Next.js application:

  1. The first thing we need to do is to create some scripts in our package.json. In each script, we need to specify the src directory. Otherwise, it will try to start Next from the root instead of the src path:
  "scripts": {    "start": "next start src",    "dev": "next src",    "build": "next build src"  }
File: package.json
  1. The main directory in Next is called pages. This is where we will include all the pages we want to render using Next:
 cd src && mkdir pages
  1. The first page we need to create is index.jsx:
  const Index = () => <h1>Home</h1>;  export default Index;
File: src/pages/index.jsx
  1. Now let's run our application using the dev script: ...

Get React Cookbook 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.