Skip to main content
Extension.js detects React from your project dependencies and configures JSX/TSX transforms, React module aliases, and fast-refresh support for development automatically.

When React is a good fit

  • You are building rich UI surfaces like popup, options, sidebar, or new tab.
  • You want component reuse across extension pages and content-script UI mounts.
  • You already use React in web projects and want the same development model in extensions.

Template examples

new-react

new-react template screenshot Build a React new-tab experience with a ready-to-run project structure.
Repository: extension-js/examples/newtab-react

content-react

content-react template screenshot Inject React UI into existing pages with a content-script-first setup.
Repository: extension-js/examples/content-react

new-react-router

new-react-router template screenshot React extension with client-side routing using React Router.
Repository: extension-js/examples/newtab-react-router

Usage with an existing extension

Add React to an existing extension with the steps below.

Installation

Install React runtime dependencies:
If you use TypeScript, also install React type packages:
The React integration also uses optional packages such as react-refresh and @rspack/plugin-react-refresh. Both ship as dependencies of extension-develop, so a healthy install already resolves them. When one cannot be resolved, the build fails to start and the error names the packages to install. The install command in the error is phrased for the package manager that your project uses.

Configuration

Common React file patterns:
  • JavaScript: *.jsx
  • TypeScript: *.tsx

Development behavior

In development mode, Extension.js enables React refresh integration when it detects React.
  • Extension.js uses react-refresh and @rspack/plugin-react-refresh for refresh behavior.
  • If the refresh packages cannot be resolved from your project or from extension-develop, the build fails to start and prints that install command. Extension.js does not install them for you and does not ask for a restart.
  • Extension.js applies React aliases to keep a single React/runtime instance in your bundle.

Usage examples

In a new tab extension

Example page entry:

In a content_script file

For content scripts, render React into an injected root element:

Next steps

Video walkthrough