OneCompiler

How to setup a next.js project

196


In this post, we will see how to setup a nextjs project.

Automatic setup

Run the below command to setup a nextjs project with single command.

npx create-next-app app_name

or

yarn create next-app app_name

Manual setup

Create a folder and initialize it with package.json

yarn init --yes

or 

npm init

Install next, react and react-dom

yarn add next react react-dom

or

npm install next react react-dom

Open package.json and add below code

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start"
}

dev - Runs Next.js in development mode.

build - Runs application for production usage.

start - Runs Next.js production server.