How to install Next.js

By

Learn how to install Next.js 16 with create-next-app, or manually with npm i next react react-dom, then start the App Router dev server.

~~~

To install Next.js, you need to have Node.js installed.

Next.js latest stable is 16.3.4. It needs Node 20.9.0 or newer. Check with node -v in your terminal, and compare it to the latest LTS version listed on https://nodejs.org/.

After you install Node.js, you will have the npm command available into your command line.

If you have any trouble at this stage, I recommend the following tutorials I wrote for you:

Official Next.js docs start new apps with:

npx create-next-app@latest my-app --yes
cd my-app
npm run dev

The --yes flag accepts the defaults. That setup includes TypeScript, Tailwind CSS, ESLint, the App Router, Turbopack, and an import alias.

Open http://localhost:3000 in your browser to see the app.

The screenshots later in this post are from an older Pages Router install. The commands above are the current path.

Manual install

If you want to wire the packages yourself, create a folder and initialize it:

mkdir my-app
cd my-app
npm init -y

Then install Next.js, React, and React DOM:

npm i next@latest react@latest react-dom@latest

Open package.json and set the scripts to:

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

Next.js uses the App Router by default. Create app/page.js:

export default function Home() {
  return (
    <div>
      <h1>Home page</h1>
    </div>
  )
}

Then start the development server:

npm run dev

This makes the app available on port 3000, on localhost.

npm run dev

Open http://localhost:3000 in your browser to see it.

The first Next app screen

Those screenshots show an older Next 9 / Pages Router project. The flow is the same idea: install, add a page, run npm run dev.

Tagged: Next.js · All topics

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about next: