Skip to content

@nx/react - Migrations

For an overview of the plugin and setup instructions, see the @nx/react introduction.

The @nx/react plugin provides various migrations to help you migrate to newer versions of react projects within your Nx workspace. Below is a complete reference for all available migrations.

update-23-2-0-add-optional-module-federation-packages

Section titled “update-23-2-0-add-optional-module-federation-packages”

Version: 23.2.0-beta.4

Add optional Module Federation packages when existing targets require them.

Adds @nx/module-federation, express, and http-proxy-middleware to the workspace when existing targets require them.

These packages are no longer direct dependencies of @nx/react; they are now optional peer dependencies, so installing @nx/react no longer pulls the Module Federation toolchain into workspaces that never use it. This migration backfills them for workspaces that already use Module Federation so those builds keep working after upgrading. Packages that are already present are left untouched.

A package is added only when a matching target exists:

  • @nx/module-federation: an @nx/react:module-federation-dev-server, @nx/react:module-federation-ssr-dev-server, or @nx/react:module-federation-static-server target, or a project with a module-federation.config.{js,ts} file (covers remotes whose host lives in another workspace).
  • express and http-proxy-middleware: an @nx/react:module-federation-static-server target, which proxies the static remotes.

Targets that inherit their executor from an nx.json targetDefaults entry are detected too.

For a workspace with an @nx/react:module-federation-dev-server serve target, the migration adds the Module Federation packages to devDependencies.

package.json
{
"devDependencies": {
"@nx/react": "23.1.0",
},
}
package.json
{
"devDependencies": {
"@nx/module-federation": "23.2.0",
"@nx/react": "23.1.0",
},
}

Version: 23.2.0-beta.4

Add @svgr/webpack when a webpack config references it.

Adds @svgr/webpack to the workspace when a webpack config references it.

@svgr/webpack is no longer a dependency of @nx/react, so workspaces whose webpack configs resolve it - which is what the Nx 22 add-svgr-to-webpack-config migration inlined - must declare it themselves. This migration backfills it for those workspaces. Configs referenced by executor targets are checked, as well as the conventional config file names at each project root. Workspaces that already have @svgr/webpack are left untouched.

package.json
{
"devDependencies": {
"@nx/react": "23.1.0",
},
}
package.json
{
"devDependencies": {
"@nx/react": "23.1.0",
"@svgr/webpack": "^8.0.1",
},
}

update-23-1-0-create-ai-instructions-for-react-19

Section titled “update-23-1-0-create-ai-instructions-for-react-19”

Version: 23.1.0-beta.0

Create AI instructions to help migrate workspaces from React 18 to 19.

NameVersion
react>=19.0.0

Bumps react, react-dom, and the React type packages from 18 to 19. React 19 removes several long-deprecated APIs; the change every project hits is the root API (ReactDOM.render -> createRoot). Read more in the React 19 upgrade guide.

The paired AI instructions migration walks an agent through the full set of changes. The common ones are shown below.

src/main.tsx
import ReactDOM from 'react-dom';
ReactDOM.render(<App />, document.getElementById('root'));
src/main.tsx
import { createRoot } from 'react-dom/client';
createRoot(document.getElementById('root')!).render(<App />);

defaultProps on a function component becomes a default parameter:

function Badge({ color }) {}
Badge.defaultProps = { color: 'gray' };
function Badge({ color = 'gray' }) {}

Version: 23.1.0-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
react^19.0.0Updated only
react-dom^19.0.0Updated only
react-is^19.0.0Updated only
@types/react^19.0.0Updated only
@types/react-dom^19.0.0Updated only
@types/react-is^19.0.0Updated only

23.1.0-eslint-plugin-react-package-updates

Section titled “23.1.0-eslint-plugin-react-package-updates”

Version: 23.1.0-beta.5

The following packages will be updated:

NameVersionAlways add to package.json
eslint-plugin-react^7.35.0Updated only

update-23-0-0-remove-nx-react-webpack-plugin-import

Section titled “update-23-0-0-remove-nx-react-webpack-plugin-import”

Version: 23.0.0-beta.10

Rewrites imports of NxReactWebpackPlugin from ‘@nx/react’ to the sub-path ‘@nx/react/webpack-plugin’.

Rewrite NxReactWebpackPlugin Imports to the @nx/react/webpack-plugin Sub-path

Section titled “Rewrite NxReactWebpackPlugin Imports to the @nx/react/webpack-plugin Sub-path”

The deprecated re-export of NxReactWebpackPlugin from @nx/react is removed in v23. The migration rewrites both ES module imports and CJS require() calls to use the @nx/react/webpack-plugin sub-path. Imports that combine the deprecated symbol with other named imports are split into two declarations so the rest of the original import still resolves from @nx/react. Aliases (as Plugin, : Plugin) are preserved.

ES module import.

apps/my-app/webpack.config.ts
import { NxReactWebpackPlugin } from '@nx/react';
export default { plugins: [new NxReactWebpackPlugin()] };
apps/my-app/webpack.config.ts
import { NxReactWebpackPlugin } from '@nx/react/webpack-plugin';
export default { plugins: [new NxReactWebpackPlugin()] };

ES module import combined with other named imports.

apps/my-app/webpack.config.ts
import { NxReactWebpackPlugin, withReact } from '@nx/react';
apps/my-app/webpack.config.ts
import { NxReactWebpackPlugin } from '@nx/react/webpack-plugin';
import { withReact } from '@nx/react';

CJS require().

apps/my-app/webpack.config.js
const { NxReactWebpackPlugin } = require('@nx/react');
apps/my-app/webpack.config.js
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');

update-23-0-0-migrate-create-nodes-v2-import

Section titled “update-23-0-0-migrate-create-nodes-v2-import”

Version: 23.0.0-beta.24

Rename imports of createNodesV2 from @nx/react/router-plugin to the canonical createNodes export.

Rename createNodesV2 imports to createNodes

Section titled “Rename createNodesV2 imports to createNodes”

@nx/react renamed its primary inferred-plugin export from createNodesV2 to createNodes. The createNodesV2 name is preserved as a deprecated alias for now, but new code should use createNodes.

This migration scans every .ts, .tsx, .cts, and .mts file in your workspace and rewrites named imports and re-exports of createNodesV2 from @nx/react/router-plugin to createNodes.

import { createNodesV2 } from '@nx/react/router-plugin';
import { createNodes } from '@nx/react/router-plugin';

Aliases are preserved (createNodesV2 as cn becomes createNodes as cn), and if a file already imports both names ({ createNodes, createNodesV2 }) the redundant binding is dropped.

Only static import/export named bindings from @nx/react/router-plugin are rewritten. Namespace imports, dynamic import(...), require(...) destructuring, and property access such as plugin.createNodesV2 are left untouched — they keep working through the createNodesV2 runtime alias. Update those by hand if you want to drop the deprecated name everywhere.

Version: 23.0.0-beta.25

Rewrites @nx/react/src/* subpath imports now that the ./src/* subpath is no longer exposed by @nx/react’s exports map. Named imports/exports of public symbols are routed to @nx/react and the rest to the new @nx/react/internal entry; require, dynamic import and jest.mock calls reference the whole module and are routed to @nx/react/internal.

Version: 22.7.0-beta.18

The following packages will be updated:

NameVersionAlways add to package.json
react-router7.14.2Updated only
@react-router/dev7.14.2Updated only
@react-router/node7.14.2Updated only
@react-router/serve7.14.2Updated only
@react-router/express7.14.2Updated only
@react-router/fs-routes7.14.2Updated only
@react-router/cloudflare7.14.2Updated only
@react-router/architect7.14.2Updated only
@react-router/remix-routes-option-adapter7.14.2Updated only

Version: 22.6.0-beta.10

The following packages will be updated:

NameVersionAlways add to package.json
@module-federation/enhanced^2.1.0Updated only
@module-federation/node^2.7.21Updated only

Version: 22.3.4-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
react-router-dom6.30.3Updated only

Version: 22.3.4-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
react-router7.12.0Updated only
@react-router/dev7.12.0Updated only
@react-router/node7.12.0Updated only
@react-router/serve7.12.0Updated only
@react-router/express7.12.0Updated only
@react-router/fs-routes7.12.0Updated only
@react-router/cloudflare7.12.0Updated only
@react-router/architect7.12.0Updated only
@react-router/remix-routes-option-adapter7.12.0Updated only

Version: 22.2.0-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
@module-federation/enhanced^0.21.2Updated only
@module-federation/runtime^0.21.2Updated only
@module-federation/sdk^0.21.2Updated only
@module-federation/node^2.7.21Updated only

Version: 22.2.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@emotion/react11.14.0Updated only
@emotion/styled11.14.1Updated only
@emotion/babel-plugin11.13.5Updated only

Version: 22.0.0-beta.0

Updates webpack configs using React to use the new withSvgr composable function instead of the svgr option in withReact or NxReactWebpackPlugin.

Version: 21.4.0-beta.8

The following packages will be updated:

NameVersionAlways add to package.json
http-proxy-middleware^3.0.5Updated only

Version: 21.0.0-beta.11

Replaces classProperties.loose option with loose.

Replace classProperties.loose option in .babelrc

Section titled “Replace classProperties.loose option in .babelrc”

The classProperties.loose option is replaced by loose in .babelrc files.

.babelrc
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"classProperties": {
"loose": true
},
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
.babelrc
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"loose": true,
"useBuiltIns": "usage"
}
]
],
"plugins": []
}