First, create an empty project folder and initialize npm in it:
$ mkdir next-js-condensed
$ cd next-js-condensed
$ npm init
After that, let's install the Next.js package:
$ npm install nextjs@latest --save-dev
$ npm install react@latest react-dom@latest --save
We save Next.js to devDependencies to clearly separate dependencies for the client and for the server. Server-side dependencies will be in the devDependencies section; the client's will be in the regular section.
If you're using Git or any similar source control tool, it makes sense to add an ignore file that will remove the build artifacts folder from source control. We show an example .gitignore file here:
.DS_Store
.idea
.next
.vscode
build
coverage
node_modules
npm-debug*
out
yarn-debug*
yarn-error*