Next.js
Required plugins:
JavaScript and TypeScript
, Next.js Support
- The plugins are bundled with JetBrains Rider and enabled by default.
JetBrains Rider integrates with the Next.js React framework.
Download and install Node.js.
Make sure the JavaScript and TypeScript plugin is enabled in the settings. Press CtrlAlt0S to open settings and then select Plugins. Click the Installed tab. In the search field, type JavaScript and TypeScript. For more information about plugins, refer to Managing plugins.
Install and enable the Next.js Support plugin on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains Marketplace.
The recommended way to start building a new Next.js application is the create-next-app
package, which JetBrains Rider downloads and runs for you using 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 JetBrains Rider project and install Next.js in it.
tip
Learn more about starting with Next.js from the Next.js official website.
Click New Solution on the Welcome screen or select File | New Solution from the main menu. The New Solution dialog opens.
In the left-hand pane, choose Next.js.
In the right-hand pane:
Specify the path to the folder where the project-related files will be stored.
In the Node Interpreter field, specify the Node.js interpreter to use. Select a configured interpreter 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 runningnpm install --save-dev next react react-dom
in the Terminal Ctrl0`. When creating an application, select the folder where thecreate-next-app
package is stored.Optionally:
To use TypeScript instead of JavaScript, select the Use TypeScript template checkbox. JetBrains Rider will generate .ts files for your application and a tsconfig.json configuration file.
When you click Create, JetBrains Rider generates a Next.js-specific project with all the required configuration files and downloads the required dependencies. JetBrains Rider also creates an npm start and JavaScript Debug configurations with default settings for running or debugging your application.
tip
Alternatively, open the built-in Terminal and type:
npx create-next-app <application-name>
to create an application.
cd <application-name>
to switch to the application folder.
npm start
to start the Node.js server.
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.
Click New Solution on the Welcome screen or select File | New Solution from the main menu. The New Solution dialog opens.
In the left-hand pane, choose Empty Project. In the right-hand pane, specify the application folder and click Create.
Open the empty project where you will use Next.js.
In the embedded Terminal (Ctrl0`) , type:
npm install --save-dev next react react-dom
To continue developing an existing Next.js application, open it in JetBrains Rider and download the required dependencies.
Click Open on the Welcome screen or select File | Open | Open from the main menu. In the dialog that opens, select the folder where your sources are stored.
Click Clone Repository on the Welcome screen.
Alternatively, select 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.
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).
Click Run 'npm install' or Run 'yarn install' in the popup:
You can use npm, Yarn 1, or Yarn 2, refer to npm and Yarn for details.
Alternatively, select Run 'npm install' or Run 'yarn install' from the context menu of package.json in the editor or in the Explorer tool window CtrlAlt0L.
When you open a project that was created outside JetBrains Rider and was imported into it, JetBrains Rider 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, JetBrains Rider 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.
JetBrains Rider 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, JetBrains Rider opens and loads a project. That means the project is initialized, project's plugins are resolved, dependencies are added, and all JetBrains Rider features are available.
Don't Open: in this case, JetBrains Rider doesn't open the project.
tip
Projects created from the Welcome screen or via File | New | Project as described in are automatically considered trusted.
Please, refer to Run a React application and Debug a React application.