IntelliJ IDEA 2026.1 Help

React

React is a JavaScript library for building complex interactive User Interfaces from encapsulated components. Learn more about the library from the React official website.

IntelliJ IDEA integrates with React providing assistance in configuring, editing, linting, running, debugging, and maintaining your applications.

Before you start

  1. Make sure you have Node.js on your computer.

  2. Make sure the JavaScript and TypeScript and JavaScript Debugger required plugins are enabled on the Settings | Plugins page, tab Installed. For more information, refer to Managing plugins.

  3. Install the React and Vite plugins on the Settings | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains Marketplace.

Create a new React application

The recommended way to start a new React single page application is the create-vite package, which IntelliJ IDEA downloads and runs for you using npx. As a result, your development environment is preconfigured to use Vite with React and TypeScript, learn more from the Vite official website.

Generate a React application with create-vite

  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 Vite 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 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 Vite list, select npx create-vite.

    From the Template list, select react.

  5. Optional:

    To use TSX instead of JSX, select the Create TypeScript project checkbox. IntelliJ IDEA will generate .tsx files for your application and a tsconfig.json configuration file.

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

Install React in an empty IntelliJ IDEA project

In this case, you will have to configure the build pipeline yourself as described in Building a React application below. Learn more about adding React to a project from the React official website.

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.

Install React in an empty project

  1. Open the empty project where you will use React.

  2. In the embedded Terminal (Alt+F12) , type:

    npm install --save react react-dom

Start with an existing React application

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

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.

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).

Download the dependencies

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

    Open an application and download the dependencies

    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 Project tool window (Alt+1) .

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.

Code completion

IntelliJ IDEA provides code completion for React APIs and JSX in JavaScript code. Code completion works for React methods, React-specific attributes, HTML tags and component names, React events, component properties, and so on. Learn more from the React official website.

To get code completion for React methods and React-specific attributes, you need to have the react.js library file somewhere in your project. Usually the library is already in your node_modules folder.

Complete React methods, attributes, and events

By default, the code completion popup is displayed automatically as you type. For example:

Completion popup

In JSX tags, IntelliJ IDEA provides coding assistance for React-specific attributes, such as className or classID, and non-DOM attributes, such as key or ref. Moreover, auto-completion also works for names of classes defined in the project’s CSS files:

Completion for CSS class names

All React events, such as onClick or onChange, can also be completed automatically together with curly braces  ={} or quotes "".

Complete React events

By default, curly braces are inserted. You can have IntelliJ IDEA always add quotes or choose between quotes or braces based on the type from a TypeScript definition file (d.ts). To change the default setting, open the Settings dialog (Ctrl+Alt+S) , go to Editor | Code Style | HTML and select the applicable option from the Add for JSX attributes list.

Add for JSX attributes

Completion also works for JavaScript expressions inside curly braces. This applies to all the methods and functions that you have defined:

Completing JavaScript expressions inside curly braces

Complete HTML tags and component names

IntelliJ IDEA provides code completion for HTML tags and component names that you have defined inside methods in JavaScript or inside other components:

Completion for HTML tags and component names

Completion also works for imported components with ES6 style syntax:

Completion for imported components with ES6 syntax

Complete component properties

IntelliJ IDEA provides code completion for component properties defined using propTypes and resolves them so you can quickly jump or preview their definitions:

Completion for component properties

When you autocomplete the name of a component, IntelliJ IDEA adds all its required properties automatically. If some of the required properties are missing in the usage of a component, IntelliJ IDEA warns you about that.

Add state to functional components

IntelliJ IDEA suggests a quick-fix to add useState hooks to functional React components by defining unresolved references in certain places. IntelliJ IDEA automatically inserts import statements for the useState hook. The state type is inferred from the place where the reference is defined.

  • Place the caret at an unresolved reference, press Alt+Enter, and select Create <unresolved reference> state in < functional component name> component from the list.

Add props

IntelliJ IDEA suggests a quick fix to add new properties to React components by defining unresolved references in certain places.

IntelliJ IDEA generates the code of components with the added properties. The type of a property is inferred from the place where the corresponding reference is defined.

The quick fix can be also applied in class-based components. In such cases, an unresolved reference is replaced with this.props.${reference_name} after a new property is inserted.

  • Place the caret at an unresolved reference, press Alt+Enter, and select Create <unresolved reference>prop in <component name> component from the list.

    Add props

Transfer HTML attributes to JSX

When you copy a piece of HTML code with class attributes or on-event handlers and paste it into JSX, IntelliJ IDEA automatically replaces these attributes with React-specific ones (className, onClick, onChange, and so on.)

Transfer HTML to JSX

This also works for TSX:

Transfer HTML to TSX

When you copy a piece of HTML code that contains single tags and paste it into JSX, IntelliJ IDEA automatically adds a slash / at the end of each single tag.

Transfer HTML to JSX: close single tags

To copy HTML code to JSX or TSX as is, use Paste Simple Ctrl+Alt+Shift+V or open the Settings dialog (Ctrl+Alt+S) , go to Editor | General | Smart Keys | JavaScript, settings page and clear the Close HTML single tags when pasting code into JSX files and the Convert HTML attribute names when pasting into JSX files checkboxes.

React code snippets

IntelliJ IDEA comes with a collection of more than 50 code snippets that expand into different statements and blocks of code often used in React apps, including React Hooks. The example below shows how you can use the rcjc abbreviation to create a class that defines a new React component:

Live template for a React component

Create a React code construct from a snippet

  • Type the required abbreviation in the editor and press Tab.

  • Press Ctrl+J and choose the relevant snippet. To narrow down the search, start typing the abbreviation and then select it from the completion list.

For more information, refer to Live Templates.

View the list of all available React snippets

  • In the Settings dialog (Ctrl+Alt+S) , click Live Templates under Editor, and then expand the React or React hooks node.

    Live templates: React and React hooks

React directives

IntelliJ IDEA recognizes and highlights the following React directives at the top of a file and within functions:

Emmet in JSX

With IntelliJ IDEA, you can use Emmet not only in HTML but also in your JSX code taking advantage of some special React twists. For example, the abbreviation div.my-class expands in JSX to <div className=”my-class"></div> but not to <div class=”my-class"></div> as it would in HTML:

Expand Emmet template in React

Navigate through a React application

Besides the basic navigation, IntelliJ IDEA helps you jump between React-specific code elements.

  • To jump to the declaration of a method or a JavaScript expression inside curly braces {}, select the method or expression and press Ctrl+B.

    To jump to the declaration of a component, select the component name and press Ctrl+B.

  • To view component definition, press Ctrl+Shift+I.

    View quick definition of a component in a popup
  • To view quick documentation for a component, press Ctrl+Q. Learn more from JavaScript documentation look-up.

    Quick documentation popup for React component
  • IntelliJ IDEA lets you easily navigate through JSX tags using editor breadcrumbs and colorful highlighting for the tag tree in the editor gutter.

    Highlighting and breadcrumbs for JSX tags in a React application

Navigate with the structure view

The Structure tool window and the Structure popup provide you with clearer insights into React code structures, facilitating easier navigation, and promoting better understanding of React components and related elements.

The Structure tool window shows the following React-specific nodes:

  • JSX and TSX tags with their names.

  • React component nodes show React component declarations. A separate node is created for each class or function that matches a React component definition.

    Structure view - component nodes
  • React hook nodes represent React hook declarations. A separate node is created for each function call inside React component that matches rules of hooks. Each node shows the name of a hook and its generic type.

    The variables initialized by a hook are shown as children under its node.

    Structure view - hook nodes

    For hooks that return 2 variables in the format [variableName, setVariableName] the variable name is displayed gray next to the hook name:

    Structure view - hooks with setVariable
  • Conditional nodes represent conditionally rendered JSX tag nodes. Conditions that do not contain JSX are not displayed.

    Structure view - conditional nodes
  • Attribute nodes represent JSX inside other component props. Attributes that do not contain JSX are not displayed.

    Structure view - attribute nodes
  • Array nodes represent arrays that contain JSX.

    Structure view - array nodes
  • Variable nodes represent variables that contain JSX.

  • Map nodes represent array maps inside JSX content.

    Structure view - map nodes
  • To open the Structure tool window, press Alt+7 or go to View | Tool Windows | Structure in the main menu.

  • To open the Structure popup, press Ctrl+F12 or go to Navigate | File Structure in the main menu.

  • The Structure tool window and the Structure popup are synchronized with the file in the active editor tab. As you move through the structure view, the corresponding code elements in the file are highlighted. Also if you rename an item in the source code, the corresponding node is updated accordingly.

    To jump from an item in the structure view to the source code, press F4.

Learn more from Source code navigation: File structure.

Lint a React application

All the IntelliJ IDEA built-in code inspections for JavaScript and HTML also work in JSX code. IntelliJ IDEA alerts you in case of unused variables and functions, missing closing tags, missing statements, and much more.

JavaSxript inspections in React application

For some inspections IntelliJ IDEA provides quick-fixes, for example, suggests adding a missing method. To view the quick-fix popup, press Alt+Enter.

To customize the list of inspections, open the Settings dialog (Ctrl+Alt+S) , go to Editor | Inspections, and disable the inspections you don’t want to see or change their severity levels. Learn more from Disable and suppress inspections and Change inspection severity.

ESLint

Besides providing built-in code inspections, IntelliJ IDEA also integrates with linters, such as ESLint, for JSX code. ESLint brings a wide range of linting rules that can also be extended with plugins. IntelliJ IDEA shows warnings and errors reported by ESLint right in the editor, as you type. With ESLint, you can also use JavaScript Standard Style as well as lint your TypeScript code.

For more information, refer to ESLint.

To have ESLint properly understand React JSX syntax, you need eslint-plugin-react. With this plugin, you are warned, for example, when the display name is not set for a React component, or when some dangerous JSX properties are used:

ESLint with React: errors and warnings are highlighted, the description of a problem is shown in a tooltip.

Install and configure ESLint in a React project

  1. In the built-in Terminal (View | Tool Windows | Terminal), type:

    npm install --save-dev eslint npm install --save-dev eslint-plugin-react
  2. Add an ESLint configuration file to your project.

  3. In the Settings dialog (Ctrl+Alt+S) , go to Languages & Frameworks | JavaScript | Code Quality Tools | ESLint, and select Automatic ESLint configuration. IntelliJ IDEA will automatically locate ESLint in your project node_modules folder, and then use the default configuration from .eslintrc.* file or from eslintConfig property in a package.json.

    Alternatively, select Manual ESLint configuration to use a custom ESLint package and configuration.

    See Activating and configuring ESLint in IntelliJ IDEA for details.

Example of .eslintrc structure (ESLint 1.x with react plugin)

  1. In the ecmaFeatures object, add "jsx" = true. Here you can also specify additional language features you’d like to use, for example, ES6 classes, modules, and so on.

  2. In the plugins object, add react.

  3. In the rules object, you can list ESLint built-in rules that you would like to enable, as well as rules available via the react plugin.

    { "parser": "babel-eslint", "env": { "browser": true, "es6": true, "jest": true }, "rules": { "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }], "react/jsx-props-no-spreading": "off", "react/jsx-sort-props": ["error", { "reservedFirst": ["key"] }], "react/require-default-props": "off", "react/sort-prop-types": "error", "react/state-in-constructor": ["error", "never"], "semi-spacing": "warn" }, "overrides": [ { "files": [ "sample/**", "test/**" ], "rules": { "import/no-unresolved": "off" } } ] }

Learn more about ESLint and react plugin configuration from the ESLint official website.

Build a React application

You need to set up the build process if you installed React in an existing IntelliJ IDEA project. Learn about various ways to configure a build pipeline for your React application from React official website.

Use several frameworks within a project

Sometimes you may need to use other frameworks within one React project.

To get context-aware coding assistance in each file, create a configuration file .ws-context and specify which framework should be used in each particular file or folder. The settings from this file will override the default configuration.

  1. In the project root, select New | File from the context menu and specify .ws-context as the file name.

  2. In .ws-context, use two types of properties:

    • <context-name> with the context value string

    • A GLOB pattern with a context details object

  3. Use the following context values:

    • framework: vue, angular, react, svelte, astro

    • angular-template-syntax: V_2, V_17

    • nextjs-project: nextjs

    • astro-project: astro

    • vue-store: vuex, pinia

    • vue-class-component-library: vue-class-component, vue -property-decorator, vue-facing-decorator

    • jsdoc-dialect: jsdoc-typescript, jsdoc-closure

  4. Use path nesting for simplicity.

    • The last segment of a GLOB path is the file name pattern, it only supports the * wildcard.

    • If the last segment is a ** it matches all nested directories and files.

    • Top level context properties should have the /** pattern.

  5. When several patterns match the same file name, the following rules are used for disambiguation:

    • Choose the pattern with maximum number of path segments, excluding ** segments.

    • Choose the pattern that is a pure file name pattern, which means that it does not end in ** or /.

    • Choose the pattern that was defined first.

Example

Suppose you have a project with a number of frameworks used in various folders.

A project with different frameworks

To get context-aware assistance for each file in the project, add the following code to .ws-context:

{ "framework": "vue", "angular-template-syntax": "V_2", "src/**/app/**": { "framework": null, "app.component.html" : { "framework": "angular", "angular-template-syntax": "V_17" } }, "src/**/p*-editor/*.html" : { "framework" : "angular" } }
10 February 2026