Create a new Next.js app and run it locally.
admin
Tin tức
23 tháng 10, 2025
2 phút đọc
60 lượt xem
Installation
Create a new Next.js app and run it locally.
Quick start
Create a new Next.js app named my-app
cd my-app and start the dev server.
Visit http://localhost:3000.
pnpm
npm
yarn
bun
Terminal
pnpm create next-app@latest my-app --yes
cd my-app
pnpm dev
--yes skips prompts using saved preferences or defaults. The default setup enables TypeScript, Tailwind, App Router, and Turbopack, with import alias @/*.
System requirements
Before you begin, make sure your system meets the following requirements:
Node.js 18.18 or later.
macOS, Windows (including WSL), or Linux.
Create with the CLI
The quickest way to create a new Next.js app is using create-next-app, which sets up everything automatically for you. To create a project, run:
Terminal
npx create-next-app@latest
On installation, you'll see the following prompts:
Terminal
What is your project named? my-app
Would you like to use TypeScript? No / Yes
Would you like to use ESLint? No / Yes
Would you like to use Tailwind CSS? No / Yes
Would you like your code inside a `src/` directory? No / Yes
Would you like to use App Router? (recommended) No / Yes
Would you like to use Turbopack? (recommended) No / Yes
Would you like to customize the import alias (`@/*` by default)? No / Yes
What import alias would you like configured? @/*
After the prompts, create-next-app will create a folder with your project name and install the required dependencies.
Manual installation
To manually create a new Next.js app, install the required packages:
pnpm
npm
yarn
bun
Terminal
pnpm i next@latest react@latest react-dom@latest
Good to know: The App Router uses React canary releases built-in, which include all the stable React 19 changes, as well as newer features being validated in frameworks. The Pages Router uses the React version you install in package.json.
Then, add the following scripts to your package.json file:
package.json
{
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "eslint"
}
}
These scripts refer to the different stages of developing an application:
next dev --turbopack: Starts the development server using Turbopack.
next build: Builds the application for production.
next start: Starts the production server.
eslint: Runs ESLint.
Turbopack is stable for dev. For production builds, Turbopack is in beta. To try it, run next build --turbopack. See the Turbopack docs for status and caveats.
Create the app directory
Next.js uses file-system routing, which means the routes in your application are determined by how you structure your files.
Create an app folder. Then, inside app, create a layout.tsx file. This file is the root layout. It's required and must contain the and tags.

