Unverified Commit 34b5db7e authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Next CLI flags documentation (#89750)

Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
Co-authored-by: 's avatarJoseph Chamochumbi <joseph.chamochumbi@vercel.com>
parent 486f6744
......@@ -65,10 +65,22 @@ Learn more about [browser support](/docs/architecture/supported-browsers), inclu
The quickest way to create a new Next.js app is using [`create-next-app`](/docs/app/api-reference/cli/create-next-app), which sets up everything automatically for you. To create a project, run:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app
```
```bash package="npm"
npx create-next-app@latest
```
```bash package="yarn"
yarn create next-app
```
```bash package="bun"
bun create next-app
```
On installation, you'll see the following prompts:
```txt filename="Terminal"
......
......@@ -14,8 +14,20 @@ related:
To update to the latest version of Next.js, you can use the `upgrade` command:
```bash filename="Terminal"
next upgrade
```bash package="pnpm"
pnpm next upgrade
```
```bash package="npm"
npx next upgrade
```
```bash package="yarn"
yarn next upgrade
```
```bash package="bun"
bunx next upgrade
```
Next.js 15 and earlier do not support the `upgrade` command and need to use a separate package instead:
......@@ -46,10 +58,22 @@ bun add next@latest react@latest react-dom@latest eslint-config-next@latest
To update to the latest canary, make sure you're on the latest version of Next.js and everything is working as expected. Then, run the following command:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add next@canary
```
```bash package="npm"
npm i next@canary
```
```bash package="yarn"
yarn add next@canary
```
```bash package="bun"
bun add next@canary
```
### Features available in canary
The following features are currently available in canary:
......
......@@ -12,12 +12,24 @@ related:
Next.js supports the "Backend for Frontend" pattern. This lets you create public endpoints to handle HTTP requests and return any content type—not just HTML. You can also access data sources and perform side effects like updating remote data.
If you are starting a new project, using `create-next-app` with the `--api` flag automatically includes an example `route.ts` in your new project’s `app/` folder, demonstrating how to create an API endpoint.
If you are starting a new project, using `create-next-app` with the `--api` flag automatically includes an example `route.ts` in your new project's `app/` folder, demonstrating how to create an API endpoint.
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --api
```
```bash package="npm"
npx create-next-app@latest --api
```
```bash package="yarn"
yarn create next-app --api
```
```bash package="bun"
bun create next-app --api
```
> **Good to know**: Next.js backend capabilities are not a full backend replacement. They serve as an API layer that:
>
> - is publicly reachable
......
......@@ -113,11 +113,20 @@ For React-specific debugging, install the [React Developer Tools](https://react.
To debug server-side Next.js code with browser DevTools, you need to pass the `--inspect` flag:
```bash filename="Terminal"
next dev --inspect
# or
next start --inspect
# next build --inspect is currently not supported
```bash package="pnpm"
pnpm dev --inspect
```
```bash package="npm"
npm run dev -- --inspect
```
```bash package="yarn"
yarn dev --inspect
```
```bash package="bun"
bun run dev --inspect
```
The value of `--inspect` is passed to the underlying Node.js process. Check out the [`--inspect` docs for advanced use cases](https://nodejs.org/api/cli.html#--inspecthostport).
......
......@@ -86,10 +86,22 @@ This package is used internally by Next.js to load environment variables from `.
To use it, install the package and use the `loadEnvConfig` function to load the environment variables:
```bash
```bash package="pnpm"
pnpm add @next/env
```
```bash package="npm"
npm install @next/env
```
```bash package="yarn"
yarn add @next/env
```
```bash package="bun"
bun add @next/env
```
```tsx filename="envConfig.ts" switcher
import { loadEnvConfig } from '@next/env'
......@@ -145,7 +157,7 @@ Non-`NEXT_PUBLIC_` environment variables are only available in the Node.js envir
In order to make the value of an environment variable accessible in the browser, Next.js can "inline" a value, at build time, into the js bundle that is delivered to the client, replacing all references to `process.env.[variable]` with a hard-coded value. To tell it to do this, you just have to prefix the variable with `NEXT_PUBLIC_`. For example:
```txt filename="Terminal"
```txt filename=".env"
NEXT_PUBLIC_ANALYTICS_ID=abcdefghijk
```
......
......@@ -54,15 +54,42 @@ Make sure you're using the latest version of Next.js. Each new version often inc
Turbopack is now the default bundler for Next.js development and provides significant performance improvements over webpack.
```bash
```bash package="pnpm"
pnpm add next@latest
pnpm dev # Turbopack is used by default
```
```bash package="npm"
npm install next@latest
npm run dev # Turbopack is used by default
```
```bash package="yarn"
yarn add next@latest
yarn dev # Turbopack is used by default
```
```bash package="bun"
bun add next@latest
bun dev # Turbopack is used by default
```
If you need to use Webpack instead of Turbopack, you can opt-in:
```bash
npm run dev --webpack
```bash package="pnpm"
pnpm dev --webpack
```
```bash package="npm"
npm run dev -- --webpack
```
```bash package="yarn"
yarn dev --webpack
```
```bash package="bun"
bun run dev --webpack
```
[Learn more about Turbopack](/blog/turbopack-for-development-stable). See our [upgrade guides](/docs/app/guides/upgrading) and codemods for more information.
......@@ -208,10 +235,22 @@ It provides detailed information about the time taken for each module to compile
1. Make sure you have the latest version of Next.js installed.
1. Generate a Turbopack trace file:
```bash
```bash package="pnpm"
NEXT_TURBOPACK_TRACING=1 pnpm dev
```
```bash package="npm"
NEXT_TURBOPACK_TRACING=1 npm run dev
```
```bash package="yarn"
NEXT_TURBOPACK_TRACING=1 yarn dev
```
```bash package="bun"
NEXT_TURBOPACK_TRACING=1 bun dev
```
1. Navigate around your application or make edits to files to reproduce the problem.
1. Stop the Next.js development server.
1. A file called `trace-turbopack` will be available in the `.next/dev` folder.
......
......@@ -54,10 +54,22 @@ For more configuration options, see the [next-devtools-mcp repository](https://g
1. Start your Next.js development server:
```bash filename="Terminal"
```bash package="pnpm"
pnpm dev
```
```bash package="npm"
npm run dev
```
```bash package="yarn"
yarn dev
```
```bash package="bun"
bun dev
```
2. Your Coding Agent will automatically connect to the running Next.js instance via `next-devtools-mcp`
3. Open your application in the browser to view pages
......
......@@ -32,10 +32,22 @@ The `@next/mdx` package, and related packages, are used to configure Next.js so
Install these packages to render MDX with Next.js:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
```
```bash package="npm"
npm install @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
```
```bash package="yarn"
yarn add @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
```
```bash package="bun"
bun add @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
```
## Configure `next.config.mjs`
Update the `next.config.mjs` file at your project's root to configure it to use MDX:
......
......@@ -20,18 +20,42 @@ The minimum Node.js version is now **v18.17**. See the [Node.js documentation](h
To update to Next.js version 13, run the following command using your preferred package manager:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add next@latest react@latest react-dom@latest
```
```bash package="npm"
npm install next@latest react@latest react-dom@latest
```
```bash package="yarn"
yarn add next@latest react@latest react-dom@latest
```
```bash package="bun"
bun add next@latest react@latest react-dom@latest
```
### ESLint Version
If you're using ESLint, you need to upgrade your ESLint version:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D eslint-config-next@latest
```
```bash package="npm"
npm install -D eslint-config-next@latest
```
```bash package="yarn"
yarn add -D eslint-config-next@latest
```
```bash package="bun"
bun add -D eslint-config-next@latest
```
> **Good to know**: You may need to restart the ESLint server in VS Code for the ESLint changes to take effect. Open the Command Palette (`cmd+shift+p` on Mac; `ctrl+shift+p` on Windows) and search for `ESLint: Restart ESLint Server`.
## Next Steps
......@@ -121,10 +145,22 @@ We recommend reducing the combined complexity of these updates by breaking down
Update to the latest Next.js version (requires 13.4 or greater):
```bash
```bash package="pnpm"
pnpm add next@latest
```
```bash package="npm"
npm install next@latest
```
```bash package="yarn"
yarn add next@latest
```
```bash package="bun"
bun add next@latest
```
Then, create a new `app` directory at the root of your project (or `src/` directory).
### Step 2: Creating a Root Layout
......
......@@ -55,10 +55,22 @@ Our goal is to get a working Next.js application as quickly as possible so that
Install Next.js in your existing project:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add next@latest
```
```bash package="npm"
npm install next@latest
```
```bash package="yarn"
yarn add next@latest
```
```bash package="bun"
bun add next@latest
```
### Step 2: Create the Next.js Configuration File
Create a `next.config.ts` at the root of your project (same level as your `package.json`). This file holds your [Next.js configuration options](/docs/app/api-reference/config/next-config-js).
......@@ -470,10 +482,22 @@ next-env.d.ts
Now you can run:
```bash
```bash package="pnpm"
pnpm dev
```
```bash package="npm"
npm run dev
```
```bash package="yarn"
yarn dev
```
```bash package="bun"
bun dev
```
Open [http://localhost:3000](http://localhost:3000). You should see your application now running on Next.js (in SPA mode).
### Step 11: Clean Up
......
......@@ -56,10 +56,22 @@ chances of encountering issues during the migration process and reduces merge co
The first thing you need to do is to install `next` as a dependency:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add next@latest
```
```bash package="npm"
npm install next@latest
```
```bash package="yarn"
yarn add next@latest
```
```bash package="bun"
bun add next@latest
```
### Step 2: Create the Next.js Configuration File
Create a `next.config.mjs` at the root of your project. This file will hold your
......
......@@ -32,10 +32,22 @@ That's why we prepared a package `@vercel/otel` that helps you get started quick
To get started, install the following packages:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add @vercel/otel @opentelemetry/sdk-logs @opentelemetry/api-logs @opentelemetry/instrumentation
```
```bash package="npm"
npm install @vercel/otel @opentelemetry/sdk-logs @opentelemetry/api-logs @opentelemetry/instrumentation
```
```bash package="yarn"
yarn add @vercel/otel @opentelemetry/sdk-logs @opentelemetry/api-logs @opentelemetry/instrumentation
```
```bash package="bun"
bun add @vercel/otel @opentelemetry/sdk-logs @opentelemetry/api-logs @opentelemetry/instrumentation
```
<AppOnly>
Next, create a custom [`instrumentation.ts`](/docs/app/guides/instrumentation) (or `.js`) file in the **root directory** of the project (or inside `src` folder if using one):
......@@ -92,10 +104,22 @@ The `@vercel/otel` package provides many configuration options and should serve
Firstly you need to install OpenTelemetry packages:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http
```
```bash package="npm"
npm install @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http
```
```bash package="yarn"
yarn add @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http
```
```bash package="bun"
bun add @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http
```
Now you can initialize `NodeSDK` in your `instrumentation.ts`.
Unlike `@vercel/otel`, `NodeSDK` is not compatible with edge runtime, so you need to make sure that you are importing them only when `process.env.NEXT_RUNTIME === 'nodejs'`. We recommend creating a new file `instrumentation.node.ts` which you conditionally import only when using node:
......@@ -189,10 +213,22 @@ OpenTelemetry Collector is not necessary. You can use a custom OpenTelemetry exp
You can add a custom span with [OpenTelemetry APIs](https://opentelemetry.io/docs/instrumentation/js/instrumentation).
```bash filename="Terminal"
```bash package="pnpm"
pnpm add @opentelemetry/api
```
```bash package="npm"
npm install @opentelemetry/api
```
```bash package="yarn"
yarn add @opentelemetry/api
```
```bash package="bun"
bun add @opentelemetry/api
```
The following example demonstrates a function that fetches GitHub stars and adds a custom `fetchGithubStars` span to track the fetch request's result:
```ts
......
......@@ -106,14 +106,22 @@ The [`@next/bundle-analyzer`](https://www.npmjs.com/package/@next/bundle-analyze
Install the plugin by running the following command:
```bash
npm i @next/bundle-analyzer
# or
yarn add @next/bundle-analyzer
# or
```bash package="pnpm"
pnpm add @next/bundle-analyzer
```
```bash package="npm"
npm install @next/bundle-analyzer
```
```bash package="yarn"
yarn add @next/bundle-analyzer
```
```bash package="bun"
bun add @next/bundle-analyzer
```
Then, add the bundle analyzer's settings to your `next.config.js`.
```js filename="next.config.js"
......
......@@ -513,10 +513,22 @@ To use the Web Push API, you need to generate [VAPID](https://vapidkeys.com/) ke
First, install web-push globally:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -g web-push
```
```bash package="npm"
npm install -g web-push
```
```bash package="yarn"
yarn global add web-push
```
```bash package="bun"
bun add -g web-push
```
Generate the VAPID keys by running:
```bash filename="Terminal"
......
......@@ -10,10 +10,22 @@ Next.js has built-in support for integrating with Sass after the package is inst
First, install [`sass`](https://github.com/sass/sass):
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D sass
```
```bash package="npm"
npm install --save-dev sass
```
```bash package="yarn"
yarn add -D sass
```
```bash package="bun"
bun add -D sass
```
> **Good to know**:
>
> Sass supports [two different syntaxes](https://sass-lang.com/documentation/syntax), each with their own extension.
......
......@@ -139,12 +139,24 @@ module.exports = {
}
```
Then, run `next` (normally `npm run dev` or `yarn dev`) and Next.js will guide you through the installation of the required packages to finish the setup:
Then, run the development server and Next.js will guide you through the installation of the required packages to finish the setup:
```bash filename="Terminal"
```bash package="pnpm"
pnpm dev
```
```bash package="npm"
npm run dev
```
```bash package="yarn"
yarn dev
```
```bash package="bun"
bun dev
```
You'll see instructions like these: Please install Partytown by running `npm install @qwik.dev/partytown`
Once setup is complete, defining `strategy="worker"` will automatically instantiate Partytown in your application and offload the script to a web worker.
......
......@@ -16,22 +16,42 @@ description: Learn how to set up Cypress with Next.js for End-to-End (E2E) and C
You can use `create-next-app` with the [with-cypress example](https://github.com/vercel/next.js/tree/canary/examples/with-cypress) to quickly get started.
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example with-cypress with-cypress-app
```
```bash package="npm"
npx create-next-app@latest --example with-cypress with-cypress-app
```
```bash package="yarn"
yarn create next-app --example with-cypress with-cypress-app
```
```bash package="bun"
bun create next-app --example with-cypress with-cypress-app
```
</AppOnly>
## Manual setup
To manually set up Cypress, install `cypress` as a dev dependency:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D cypress
```
```bash package="npm"
npm install -D cypress
# or
```
```bash package="yarn"
yarn add -D cypress
# or
pnpm install -D cypress
```
```bash package="bun"
bun add -D cypress
```
Add the Cypress `open` command to the `package.json` scripts field:
......@@ -50,10 +70,22 @@ Add the Cypress `open` command to the `package.json` scripts field:
Run Cypress for the first time to open the Cypress testing suite:
```bash filename="Terminal"
```bash package="pnpm"
pnpm cypress:open
```
```bash package="npm"
npm run cypress:open
```
```bash package="yarn"
yarn cypress:open
```
```bash package="bun"
bun run cypress:open
```
You can choose to configure **E2E Testing** and/or **Component Testing**. Selecting any of these options will automatically create a `cypress.config.js` file and a `cypress` folder in your project.
## Creating your first Cypress E2E test
......
......@@ -14,32 +14,60 @@ Jest and React Testing Library are frequently used together for **Unit Testing**
You can use `create-next-app` with the Next.js [with-jest](https://github.com/vercel/next.js/tree/canary/examples/with-jest) example to quickly get started:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example with-jest with-jest-app
```
```bash package="npm"
npx create-next-app@latest --example with-jest with-jest-app
```
```bash package="yarn"
yarn create next-app --example with-jest with-jest-app
```
```bash package="bun"
bun create next-app --example with-jest with-jest-app
```
## Manual setup
Since the release of [Next.js 12](https://nextjs.org/blog/next-12), Next.js now has built-in configuration for Jest.
To set up Jest, install `jest` and the following packages as dev dependencies:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom ts-node @types/jest
```
```bash package="npm"
npm install -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom ts-node @types/jest
# or
```
```bash package="yarn"
yarn add -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom ts-node @types/jest
# or
pnpm install -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom ts-node @types/jest
```
```bash package="bun"
bun add -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom ts-node @types/jest
```
Generate a basic Jest configuration file by running the following command:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create jest@latest
```
```bash package="npm"
npm init jest@latest
# or
```
```bash package="yarn"
yarn create jest@latest
# or
pnpm create jest@latest
```
```bash package="bun"
bun create jest@latest
```
This will take you through a series of prompts to setup Jest for your project, including automatically creating a `jest.config.ts|js` file.
......@@ -369,12 +397,20 @@ it('renders homepage unchanged', () => {
Then, run the following command to run your tests:
```bash filename="Terminal"
```bash package="pnpm"
pnpm test
```
```bash package="npm"
npm run test
# or
```
```bash package="yarn"
yarn test
# or
pnpm test
```
```bash package="bun"
bun run test
```
## Additional Resources
......
......@@ -10,20 +10,40 @@ Playwright is a testing framework that lets you automate Chromium, Firefox, and
The fastest way to get started is to use `create-next-app` with the [with-playwright example](https://github.com/vercel/next.js/tree/canary/examples/with-playwright). This will create a Next.js project complete with Playwright configured.
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example with-playwright with-playwright-app
```
```bash package="npm"
npx create-next-app@latest --example with-playwright with-playwright-app
```
```bash package="yarn"
yarn create next-app --example with-playwright with-playwright-app
```
```bash package="bun"
bun create next-app --example with-playwright with-playwright-app
```
## Manual setup
To install Playwright, run the following command:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create playwright
```
```bash package="npm"
npm init playwright
# or
```
```bash package="yarn"
yarn create playwright
# or
pnpm create playwright
```
```bash package="bun"
bun create playwright
```
This will take you through a series of prompts to setup and configure Playwright for your project, including adding a `playwright.config.ts` file. Please refer to the [Playwright installation guide](https://playwright.dev/docs/intro#installation) for the step-by-step guide.
......
......@@ -12,21 +12,54 @@ Vitest and React Testing Library are frequently used together for **Unit Testing
You can use `create-next-app` with the Next.js [with-vitest](https://github.com/vercel/next.js/tree/canary/examples/with-vitest) example to quickly get started:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example with-vitest with-vitest-app
```
```bash package="npm"
npx create-next-app@latest --example with-vitest with-vitest-app
```
```bash package="yarn"
yarn create next-app --example with-vitest with-vitest-app
```
```bash package="bun"
bun create next-app --example with-vitest with-vitest-app
```
## Manual Setup
To manually set up Vitest, install `vitest` and the following packages as dev dependencies:
```bash filename="Terminal"
```bash package="pnpm"
# Using TypeScript
pnpm add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom vite-tsconfig-paths
# Using JavaScript
pnpm add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
```
```bash package="npm"
# Using TypeScript
npm install -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom vite-tsconfig-paths
# Using JavaScript
npm install -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
```
```bash package="yarn"
# Using TypeScript
yarn add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom vite-tsconfig-paths
# Using JavaScript
yarn add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
```
```bash package="bun"
# Using TypeScript
bun add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom vite-tsconfig-paths
# Using JavaScript
bun add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
```
Create a `vitest.config.mts|js` file in the root of your project, and add the following options:
```ts filename="vitest.config.mts" switcher
......@@ -185,14 +218,20 @@ test('Page', () => {
Then, run the following command to run your tests:
```bash filename="Terminal"
```bash package="pnpm"
pnpm test
```
```bash package="npm"
npm run test
# or
```
```bash package="yarn"
yarn test
# or
pnpm test
# or
bun test
```
```bash package="bun"
bun run test
```
## Additional Resources
......
......@@ -14,10 +14,22 @@ All third-party integrations provided by `@next/third-parties` have been optimiz
To get started, install the `@next/third-parties` library:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add @next/third-parties@latest next@latest
```
```bash package="npm"
npm install @next/third-parties@latest next@latest
```
```bash package="yarn"
yarn add @next/third-parties@latest next@latest
```
```bash package="bun"
bun add @next/third-parties@latest next@latest
```
{/* To do: Remove this paragraph once package becomes stable */}
`@next/third-parties` is currently an **experimental** library under active development. We recommend installing it with the **latest** or **canary** flags while we work on adding more third-party integrations.
......
......@@ -10,14 +10,38 @@ description: Upgrade your Next.js Application from Version 14 to 15.
To update to Next.js version 15, you can use the `upgrade` codemod:
```bash filename="Terminal"
```bash package="pnpm"
pnpm dlx @next/codemod@canary upgrade latest
```
```bash package="npm"
npx @next/codemod@canary upgrade latest
```
```bash package="yarn"
yarn dlx @next/codemod@canary upgrade latest
```
```bash package="bun"
bunx @next/codemod@canary upgrade latest
```
If you prefer to do it manually, ensure that you're installing the latest Next & React versions:
```bash filename="Terminal"
npm i next@latest react@latest react-dom@latest eslint-config-next@latest
```bash package="pnpm"
pnpm add next@latest react@latest react-dom@latest eslint-config-next@latest
```
```bash package="npm"
npm install next@latest react@latest react-dom@latest eslint-config-next@latest
```
```bash package="yarn"
yarn add next@latest react@latest react-dom@latest eslint-config-next@latest
```
```bash package="bun"
bun add next@latest react@latest react-dom@latest eslint-config-next@latest
```
> **Good to know:**
......
......@@ -59,10 +59,22 @@ Learn more in the documentation [here](/docs/app/guides/mcp).
To update to Next.js version 16, you can use the `upgrade` [codemod](/docs/app/guides/upgrading/codemods#160):
```bash filename="Terminal"
```bash package="pnpm"
pnpm dlx @next/codemod@canary upgrade latest
```
```bash package="npm"
npx @next/codemod@canary upgrade latest
```
```bash package="yarn"
yarn dlx @next/codemod@canary upgrade latest
```
```bash package="bun"
bunx @next/codemod@canary upgrade latest
```
The [codemod](/docs/app/guides/upgrading/codemods#160) is able to:
- Update `next.config.js` to use the new `turbopack` configuration
......@@ -73,10 +85,22 @@ The [codemod](/docs/app/guides/upgrading/codemods#160) is able to:
If you prefer to do it manually, install the latest Next.js and React versions:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add next@latest react@latest react-dom@latest
```
```bash package="npm"
npm install next@latest react@latest react-dom@latest
```
```bash package="yarn"
yarn add next@latest react@latest react-dom@latest
```
```bash package="bun"
bun add next@latest react@latest react-dom@latest
```
If you are using TypeScript, ensure you also upgrade `@types/react` and `@types/react-dom` to their latest versions.
## Node.js runtime and browser support
......@@ -408,10 +432,22 @@ module.exports = nextConfig
Install the latest version of the React Compiler plugin:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D babel-plugin-react-compiler
```
```bash package="npm"
npm install -D babel-plugin-react-compiler
```
```bash package="yarn"
yarn add -D babel-plugin-react-compiler
```
```bash package="bun"
bun add -D babel-plugin-react-compiler
```
> **Good to know:** Expect compile times in development and during builds to be higher when enabling this option as the React Compiler relies on Babel.
## Caching APIs
......@@ -877,10 +913,22 @@ Additionally, a lockfile mechanism prevents multiple `next dev` or `next build`
Since the development server outputs to `.next/dev`, the [Turbopack tracing command](/docs/app/guides/local-development#turbopack-tracing) should be:
```bash
```bash package="pnpm"
pnpm next internal trace .next/dev/trace-turbopack
```
```bash package="npm"
npx next internal trace .next/dev/trace-turbopack
```
```bash package="yarn"
yarn next internal trace .next/dev/trace-turbopack
```
```bash package="bun"
bunx next internal trace .next/dev/trace-turbopack
```
## Parallel Routes `default.js` requirement
All [parallel route](/docs/app/api-reference/file-conventions/parallel-routes) slots now require explicit `default.js` files. Builds will fail without them.
......@@ -1038,10 +1086,22 @@ The `next lint` command has been removed. Use Biome or ESLint directly. `next bu
A codemod is available to automate migration:
```bash filename="Terminal"
```bash package="pnpm"
pnpm dlx @next/codemod@canary next-lint-to-eslint-cli .
```
```bash package="npm"
npx @next/codemod@canary next-lint-to-eslint-cli .
```
```bash package="yarn"
yarn dlx @next/codemod@canary next-lint-to-eslint-cli .
```
```bash package="bun"
bunx @next/codemod@canary next-lint-to-eslint-cli .
```
The `eslint` option in the Next.js config file is also removed.
```js filename="next.config.mjs"
......
......@@ -15,10 +15,22 @@ This avoids compiling everything and keeps the performance cost minimal. You may
To use it, install the `babel-plugin-react-compiler`:
```bash filename="Terminal"
```bash package="pnpm"
pnpm add -D babel-plugin-react-compiler
```
```bash package="npm"
npm install -D babel-plugin-react-compiler
```
```bash package="yarn"
yarn add -D babel-plugin-react-compiler
```
```bash package="bun"
bun add -D babel-plugin-react-compiler
```
Then, add `reactCompiler` option in `next.config.js`:
```ts filename="next.config.ts" switcher
......
......@@ -9,10 +9,22 @@ The `create-next-app` CLI allow you to create a new Next.js application using th
Basic usage:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app [project-name] [options]
```
```bash package="npm"
npx create-next-app@latest [project-name] [options]
```
```bash package="yarn"
yarn create next-app [project-name] [options]
```
```bash package="bun"
bun create next-app [project-name] [options]
```
## Reference
The following options are available:
......@@ -53,10 +65,22 @@ The following options are available:
To create a new app using the default template, run the following command in your terminal:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app
```
```bash package="npm"
npx create-next-app@latest
```
```bash package="yarn"
yarn create next-app
```
```bash package="bun"
bun create next-app
```
On installation, you'll see the following prompts:
```txt filename="Terminal"
......@@ -96,16 +120,40 @@ Once you've answered the prompts, a new project will be created with your chosen
To create a new app using an official Next.js example, use the `--example` flag. For example:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example [example-name] [your-project-name]
```
```bash package="npm"
npx create-next-app@latest --example [example-name] [your-project-name]
```
```bash package="yarn"
yarn create next-app --example [example-name] [your-project-name]
```
```bash package="bun"
bun create next-app --example [example-name] [your-project-name]
```
You can view a list of all available examples along with setup instructions in the [Next.js repository](https://github.com/vercel/next.js/tree/canary/examples).
### With any public GitHub example
To create a new app using any public GitHub example, use the `--example` option with the GitHub repo's URL. For example:
```bash filename="Terminal"
```bash package="pnpm"
pnpm create next-app --example "https://github.com/.../" [your-project-name]
```
```bash package="npm"
npx create-next-app@latest --example "https://github.com/.../" [your-project-name]
```
```bash package="yarn"
yarn create next-app --example "https://github.com/.../" [your-project-name]
```
```bash package="bun"
bun create next-app --example "https://github.com/.../" [your-project-name]
```
......@@ -9,10 +9,24 @@ The Next.js CLI allows you to develop, build, start your application, and more.
Basic usage:
```bash filename="Terminal"
```bash package="pnpm"
pnpm next [command] [options]
```
```bash package="npm"
npx next [command] [options]
```
```bash package="yarn"
yarn next [command] [options]
```
```bash package="bun"
bunx next [command] [options]
```
> **Good to know**: With `npm run`, use `--` before CLI flags so npm forwards them to `next`. This is not required for `pnpm`, `yarn`, or `bun`.
## Reference
The following options are available:
......@@ -212,10 +226,22 @@ The following options are available for the `next upgrade` command:
`next experimental-analyze` analyzes your application's bundle output using [Turbopack](/docs/app/api-reference/turbopack). This command helps you understand the size and composition of your bundles, including JavaScript, CSS, and other assets. This command doesn't produce an application build.
```bash filename="Terminal"
```bash package="pnpm"
pnpm next experimental-analyze
```
```bash package="npm"
npx next experimental-analyze
```
```bash package="yarn"
yarn next experimental-analyze
```
```bash package="bun"
bunx next experimental-analyze
```
By default, the command starts a local server after analysis completes, allowing you to explore your bundle composition in the browser. The analyzer lets you:
- Filter bundles by route and switch between client and server views
......
......@@ -209,11 +209,33 @@ Always run examples locally before committing them. This will ensure that the co
### Language and Filename
Code blocks should have a header that includes the language and the `filename`. Add a `filename` prop to render a special Terminal icon that helps orientate users where to input the command. For example:
Code blocks should have a header that includes the language and the `filename`. For example:
````mdx filename="code-example.mdx"
```bash filename="Terminal"
npx create-next-app
```tsx filename="app/page.tsx"
export default function Page() {
return <h1>Hello, Next.js!</h1>
}
```
````
For CLI commands, use the `package` prop to show the command for each package manager:
````mdx filename="code-example.mdx"
```bash package="pnpm"
pnpm create next-app
```
```bash package="npm"
npx create-next-app@latest
```
```bash package="yarn"
yarn create next-app
```
```bash package="bun"
bun create next-app
```
````
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment