Now that we have installed the dependencies, let's create our first Next.js application:
- 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
- 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
- The first page we need to create is index.jsx:
const Index = () => <h1>Home</h1>; export default Index;
File: src/pages/index.jsx
- Now let's run our application using the dev script: ...