# Next.js

> **TL;DR**
> Available only in IntelliJ IDEA with the Ultimate subscription: [download](https://www.jetbrains.com.cn/en-us/idea/download/) to try or [explore the features](https://www.jetbrains.com.cn/en-us/products/compare/?product=idea&product=idea-ult).
>
>
>
>
>
> Required plugins:
>
>
>
> `JavaScript and TypeScript` -    the plugin is bundled with IntelliJ IDEA and enabled by default.
>
>
>
> `Next.js Support` -    install the plugin on the Settings | Plugins page, tab Marketplace.     The plugin is available only in IntelliJ IDEA with the Ultimate subscription.

IntelliJ IDEA integrates with the [Next.js](https://nextjs.org/) React framework.

## Before you start

Procedure:

1. Download and install [Node.js](http://nodejs.org/#download).

2. Make sure the JavaScript and TypeScript and Next.js Support required plugins are enabled on the Settings | Plugins page, tab Installed. For more information, refer to [Managing plugins](managing-plugins.html).

## Create a new Next.js application

The recommended way to start building a new Next.js application is the `create-next-app` package, which IntelliJ IDEA downloads and runs for you using [npx](https://www.npmjs.com/package/npx). As a result, your development environment is preconfigured to use Next.js.

Of course, you can still download `create-next-app` yourself or create an empty IntelliJ IDEA project and install Next.js in it.

> **Tip:**
> Learn more about starting with Next.js from the [Next.js official
> website](https://nextjs.org/docs/getting-started).

### Generate a Next.js application with create-next-app

Procedure:

1. Select `File | New | Project` from the main menu or click the New Project button on the Welcome screen.

2. In the New Project dialog, select React in the left-hand pane.

3. In the right-hand part of the wizard, specify the project name and the folder to create it in.

4. In the  Project type area, select Next.js.

In the Node runtime field, specify the Node.js runtime to use. Select a configured runtime from the list or choose Add to configure a new one.

From the create-next-app list, select npx create-next-app.

Alternatively, for npm version 5.1 and earlier, install the `create-next-app` package yourself by running `npm install --save-dev next react react-dom` in the Terminal `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)). When creating an application, select the folder where the `create-next-app` package is stored.

5. Optionally:

To use TypeScript instead of JavaScript, select the Use TypeScript template checkbox. IntelliJ IDEA will generate `.ts` files for your application and a `tsconfig.json` configuration file.

6. When you click Create, IntelliJ IDEA generates a Next.js-specific project with all the required configuration files and downloads the required dependencies. IntelliJ IDEA also creates an npm start and a JavaScript Debug configuration with default settings for running or debugging your application.

> **Tip:**
> Alternatively, open the built-in Terminal and type:
>
>
>
> 1.
>
> `npx create-next-app <application-name>` to create an application.
>
>
>
> 2.  `cd <application-name>` to switch to the application folder.
>
> 3.  `npm start` to start the Node.js server.

### Install Next.js in an empty IntelliJ IDEA project

In this case, you will have to configure the build pipeline yourself. Learn more about adding Next.js to a project from the [Next.js official website](https://nextjs.org/docs/getting-started#manual-setup).

Procedure: Create an empty IntelliJ IDEA project

1. Select `File | New | Project` from the main menu or click the New Project button on the Welcome screen.

2. In the New Project dialog, select New Project in the left-hand pane.

3. In the right-hand pane, select JavaScript in the Language area.

4. Name the new project and change its location if necessary, then click Create.

Procedure: Install Next.js in an empty project

1. Open the empty project where you will use Next.js.

2. In your command-line shell or in the embedded Terminal (`Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)))  , type:

`npm install --save-dev next react react-dom`

## Start with an existing Next.js application

To continue developing an existing Next.js application, open it in IntelliJ IDEA and download the required dependencies.

Procedure: Open the application sources that are already on your machine

* Click Open or Import on the Welcome screen or select `File | Open`   from the main menu. In the dialog that opens, select the folder where your sources are stored.

Procedure: Check out the application sources from your version control

1. Click Clone Repository on the Welcome screen.

Alternatively, select  `File | New | Project from Version Control…` or  `Git | Clone…` or `VCS | Get from Version Control` from the main menu.

Instead of Git in the main menu, you may see any other Version Control System that is associated with your project. For example, Mercurial or Perforce.

2. In the dialog that opens, select your version control system from the list and specify the repository to check out the application sources from. For more information, refer to [Check out a
project (clone)](manage-projects-hosted-on-github.html#clone-from-GitHub).

Procedure: Download the dependencies

* Click Run 'npm install' or Run 'yarn install' in the popup:

![Open an application and download the dependencies](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_npm_yarn_package_run_npm_install_next_js.png)

You can use [npm](https://docs.npmjs.com/), [Yarn 1](https://classic.yarnpkg.com/lang/en/), or [Yarn 2](https://yarnpkg.com/), refer to [npm and Yarn](installing-and-removing-external-software-using-node-package-manager.html) for details.

* Alternatively, select Run 'npm install' or Run 'yarn install' from the context menu of `package.json` in the editor or in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) .

### Project security

When you open a project that was created outside IntelliJ IDEA and was imported into it, IntelliJ IDEA displays a dialog where you can decide how to handle this project with unfamiliar source code.

Select one of the following options:

* Preview in Safe Mode: in this case, IntelliJ IDEA opens the project in a preview mode. It means that you can browse the project's sources but you cannot run tasks and script or run/debug your project. IntelliJ IDEA displays a notification on top of the editor area, and you can click the Trust project… link and load your project at any time.

* Trust Project: in this case, IntelliJ IDEA opens and loads a project. That means the project is initialized, project's plugins are resolved, dependencies are added, and all IntelliJ IDEA features are available.

* Don't Open: in this case, IntelliJ IDEA doesn't open the project.

Learn more from [Project security](project-security.html).

> **Tip:**
> Projects created from the Welcome screen or via `File | New | Project` as described in  are automatically considered trusted.

## Run Next.js applications

To run your application, you need to launch the `next dev` command as a script and then click the application URL in the Run tool window or in the Terminal.

You can launch the `next dev` command as a script from `package.json`, in the Terminal, as described in [Run an application from the editor](#ws_next_run_via_script) or [via a run/debug configuration](#next_run_run_via_rc).

### Run an application from the editor

Procedure:

1. Сlick ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) in the gutter next to the `dev` script in `package.json`, or execute the `next dev` command in the Terminal `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)), or double-click the `dev` task in the [npm tool window](npm-tool-window.html) (`View | Tool Windows | npm`).

![Run next dev from package.json](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_script.png)

2. Wait till the application is compiled and the development server is ready.

The Run tool window or the Terminal shows the URL at which your application is running, the default URL is `http://localhost:3000`.

![Run tool window with a link to the app](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_script_run_tw_link.png)

Click this link to open the application in the browser.

### Run an application with a run/debug configuration

When you open a single-repo project with the `next` package listed as dependency in the root `package.json`, IntelliJ IDEA automatically generates a Next.js: server-side run/debug configuration of the type [npm](run-debug-configuration-npm.html). The configuration executes the `next dev` command that starts the development server and runs your application in the development mode.

> **Note:**
> * For mono-repo projects, you have to create this run/debug configuration manually.
>
> * For projects generated via the [New Project wizard](#creating_next_js_app_with_create_next_app), the run/debug configuration is generated on reopening a project.
>
> * If you remove an auto-generated run/debug configuration, it is not created anew automatically.

Procedure:

1. From the list in the Run widget on the toolbar, select a run configuration of the type npm. This can be the autogenerated Next.js: server-side configuration or a custom one that you created yourself [as described
below](#next_running_and_debugging_run_via_rc_create_rc).

![Run a Next.js app in the development mode via a run/debug configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_dev_mode.png)

Click ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg).

2. When the application is compiled and the development server is ready, the Run tool window or the Terminal shows the URL at which your application is running. The default URL is `http://localhost:3000`, however if the default port `3000` is already busy, the server tries starting on the closest free port.

![Run tool window with a link to the app](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_script_run_tw_link.png)

Click the link to open the application in the browser.

## Debug the client side of a Next.js application

With IntelliJ IDEA, you can start debugging sessions in two ways:

* [From the editor](#ws_next_run_and_debug_via_script) - run the `next dev` command as a script from `package.json` or in the Terminal. Then start a debugging session by clicking the application URL in the Run tool window or in the Terminal.

* [Using run/debug configurations](#next_running_and_debugging_run_via_rc).

### Start debugging from the editor

[Video](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_and_debug.mp4)

Procedure: Run an application with next dev

1. Сlick ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) in the gutter next to the `dev` script in `package.json`, or execute the `next dev` command in the Terminal `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)), or double-click the `dev` task in the [npm tool window](npm-tool-window.html) (`View | Tool Windows | npm`).

![Run next dev from package.json](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_script.png)

2. Wait till the application is compiled and the development server is ready.

The Run tool window or the Terminal shows the URL at which your application is running, the default URL is `http://localhost:3000`.

![Run tool window with a link to the app](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_script_run_tw_link.png)

Click this link to open the application in the browser.

Procedure: Start a debugging session from the Run tool window or from the Terminal

1. [Set breakpoints](using-breakpoints.html#set-breakpoints) where necessary.

2. Сlick ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) in the gutter next to the `dev` script in `package.json`, or execute the `next dev` command in the Terminal `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)), or double-click the `dev` task in the [npm tool window](npm-tool-window.html) (`View | Tool Windows | npm`).

3. When the application is compiled and the development server is ready, the Run tool window or the Terminal shows the URL at which your application is running. The default URL is `http://localhost:3000`, however if the default port `3000` is already busy, the server tries starting on the closest free port.

![Start a debugging session from the Run tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_debug_from_run_tw.png)

Hold `Ctrl+Shift` (Windows), `Ctrl+Shift` (macOS), `Ctrl+Shift` (IntelliJ IDEA Classic (macOS)), `Ctrl+Shift` (macOS System Shortcuts), `Ctrl+Shift` (XWin), `Ctrl+Shift` (GNOME), `Ctrl+Shift` (KDE), `Ctrl+Shift` (Emacs), `Ctrl+Shift` (Sublime Text), `Ctrl+Shift` (Sublime Text (macOS)), `Ctrl+Shift` (NetBeans), `Ctrl+Shift` (Visual Studio), `Ctrl+Shift` (Visual Studio (macOS)), `Ctrl+Shift` (Eclipse), `Ctrl+Shift` (Eclipse (macOS)) and click the link.

4. When the application opens in the browser, perform the actions that trigger the program execution, for example, click a link. The focus switches to IntelliJ IDEA with the [Debug tool window](debug-tool-window.html) open.

![Debugging session started](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_debug_from_run_tw_debug_session.png)

Proceed as usual: [step through the program](stepping-through-the-program.html),  [stop
and resume](starting-the-debugger-session.html#pause-resume)  program execution, [examine it when suspended](examining-suspended-program.html), explore the call stack and variables, set watches, evaluate variables, [view actual HTML DOM](viewing-actual-html-dom.html), and so on.

To ignore source maps and step through the actually executed code, press ![the Disable Source Maps toggle button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/sourceMapDisable.png) on the toolbar of the Debug tool window.

### Start debugging via run/debug configurations

When you open a single-repo project with the `next` package listed as dependency in the root `package.json`, IntelliJ IDEA automatically generates two run/debug configurations:

* Next.js: server-side of the type [npm](run-debug-configuration-npm.html). The configuration executes the `next dev` command that starts the development server and runs your application in the development mode.

* Next.js: debug client-side of the type [JavaScript Debug](run-debug-configuration-javascript-debug.html) to debug your application in the browser.

![Two run/debug configurations are generated](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_and_debug_two_rc_generated.png)

> **Note:**
> * For mono-repo projects, you have to create these run/debug configurations manually.
>
> * For projects generated via the [New Project wizard](#creating_next_js_app_with_create_next_app), the run/debug configurations are generated on reopening a project.
>
> * If you remove an auto-generated run/debug configuration, it is not created anew automatically.

Procedure: Create run/debug configurations

1. Go to `Run | Edit Configurations`. Alternatively, select Edit Configurations from the Run widget on the toolbar.

![Open the Edit Configurations dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/next_run_config_create.png)

In the Edit Configurations dialog that opens,

click the Add button (![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg)) on the toolbar and select npm from the list.

2. In the Configuration tab of the Run/Debug Configurations: npm dialog that opens, specify the location of the `package.json`, the Node.js runtime, and the package manager to use.

In the Command field, select run from the list and then select the script to run from the Scripts list. Most likely it will be the default `dev` script but you can configure another one in your `package.json`, for example, to run the application on a custom port.

![npm run/debug configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/next_debug_npm_rc.png)

3. Optionally:

To open the application in the browser, update the configuration as follows: in the Browser / Live Edit tab, select the After launch checkbox, select the browser to open the application in, and specify the URL address at which the application wil run.

![Browser / Live Edit tab: select browser](https://resources.jetbrains.com.cn/help/img/idea/2026.2/next_run_rc_browser_tab_select_browser.png)

> **Note:**
> If you are going to debug the application, select [Google Chrome](http://www.google.com/chrome/) or another [Chromium-based browser](https://www.chromium.org/).

Procedure: Run an application in the development mode with the npm run/debug configuration

1. From the list in the Run widget on the toolbar, select a run configuration of the type npm. This can be the autogenerated Next.js: server-side configuration or a custom one that you created yourself [as described
above](#next_running_and_debugging_run_via_rc_create_rc).

![Run a Next.js app in the development mode via a run/debug configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_dev_mode.png)

Click ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg).

2. When the application is compiled and the development server is ready, the Run tool window or the Terminal shows the URL at which your application is running. The default URL is `http://localhost:3000`, however if the default port `3000` is already busy, the server tries starting on the closest free port.

![Running Next.js app in the development mode: the Development server is ready](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_run_with_rc_run_tw.png)

Click this link to view the application.

Alternatively, enable IntelliJ IDEA to open the application on start [as
described above](#ws_next_start_app_in_dev_mode_enable_opening_browser).

> **Note:**
> When the development server is running, your application is automatically reloaded as soon as you change any of the source files and save the updates.

Procedure: Start debugging with a JavaScript Debug configuration

1. [Set breakpoints](using-breakpoints.html#set-breakpoints) where necessary.

2. Run your application in the development mode [with an npm run/debug
configuration](#next_running_and_debugging_run_via_rc_steps) or [with
next dev](#ws_next_run_and_debug_via_script).

3. When the application is compiled and the development server is ready, the Run tool window or the Terminal shows the URL at which your application is running. The default URL is `http://localhost:3000`, however if the default port `3000` is already busy, the server tries starting on the closest free port.

> **Note:**
> Make sure to specify the actual port in the JavaScript Debug configuration.

4. From the list in the Run widget on the toolbar, select a run configuration of the type JavaScript Debug. This can be the autogenerated Next.js: debug client configuration or a custom one that you created yourself [as described
above](#next_running_and_debugging_run_via_rc_create_rc).

![Start a debugging session — select the JavaScript Debug run configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/next_debug_with_rc.png)

Click ![the Debug icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.debug.svg).

5. When the application opens in the browser, perform the actions that trigger the program execution, for example, click a link. The focus switches to IntelliJ IDEA with the [Debug tool window](debug-tool-window.html) open.

Proceed as usual: [step through the program](stepping-through-the-program.html),  [stop
and resume](starting-the-debugger-session.html#pause-resume)  program execution, [examine it when suspended](examining-suspended-program.html), explore the call stack and variables, set watches, evaluate variables, [view actual HTML DOM](viewing-actual-html-dom.html), and so on.

To ignore source maps and step through the actually executed code, press ![the Disable Source Maps toggle button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/sourceMapDisable.png) on the toolbar of the Debug tool window.

Please, refer to [Run a React application](run-and-debug-react-applications.html#react_running_and_debugging_run) and [Debug a React
application](run-and-debug-react-applications.html#react_running_and_debugging_debug).

## Debug server-side components of a Next.js application

[Video](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_debug_server.mp4)

When you open a single-repo project with the `next` package listed as dependency in the root `package.json`, IntelliJ IDEA automatically generates a Next.js: server-side run/debug configuration of the type [npm](run-debug-configuration-npm.html). The configuration executes the `next dev` command that starts the development server and runs your application in the development mode.

> **Note:**
> * For mono-repo projects, you have to create this run/debug configuration manually.
>
> * For projects generated via the [New Project wizard](#creating_next_js_app_with_create_next_app), the run/debug configuration is generated on reopening a project.
>
> * If you remove an auto-generated run/debug configuration, it is not created anew automatically.

Procedure:

1. Set the breakpoints where necessary in the server-side code.

2. From the list in the Run widget on the toolbar, select a run configuration of the type npm. This can be the autogenerated Next.js: server-side configuration or a custom one that you created yourself [as described
above](#next_running_and_debugging_run_via_rc_create_rc).

![Start debugging the server-side code of a Next.js app via a run/debug configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_next_debug_server_side_start_app_in_dev_mode_rc.png)

Click ![the Debug icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.debug.svg).

3. Perform the actions that trigger the program execution, for example, click a link. The focus switches to IntelliJ IDEA with the [Debug tool window](debug-tool-window.html) open.

Proceed as usual: [step through the program](stepping-through-the-program.html),  [stop
and resume](starting-the-debugger-session.html#pause-resume)  program execution, [examine it when suspended](examining-suspended-program.html), explore the call stack and variables, set watches, evaluate variables, [view actual HTML DOM](viewing-actual-html-dom.html), and so on.

To ignore source maps and step through the actually executed code, press ![the Disable Source Maps toggle button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/sourceMapDisable.png) on the toolbar of the Debug tool window.

