
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@rspack/plugin-react-refresh
Advanced tools
React refresh plugin for Rspack.
First you need to install this plugin and its dependencies:
npm add @rspack/plugin-react-refresh react-refresh -D
# or
yarn add @rspack/plugin-react-refresh react-refresh -D
# or
pnpm add @rspack/plugin-react-refresh react-refresh -D
# or
bun add @rspack/plugin-react-refresh react-refresh -D
Import the plugin in your code:
// Named import (recommended)
import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh";
const ReactRefreshRspackPlugin = require("@rspack/plugin-react-refresh");
Enabling React Fast Refresh functionality primarily involves two aspects: code injection and code transformation.
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh");
const isDev = process.env.NODE_ENV === "development";
module.exports = {
experiments: {
rspackFuture: {
disableTransformByDefault: true,
},
},
// ...
mode: isDev ? "development" : "production",
module: {
rules: [
{
test: /\.jsx$/,
use: {
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true,
},
transform: {
react: {
development: isDev,
refresh: isDev,
},
},
},
},
},
},
],
},
plugins: [isDev && new ReactRefreshPlugin()].filter(Boolean),
};
Compared to the previous approach, this method decouples the React Fast Refresh code injection logic from the transformation logic. The code injection logic is handled uniformly by this plugin, while the code transformation is handled by loaders. This means that this plugin can be used in conjunction with builtin:swc-loader, swc-loader, or babel-loader.
builtin:swc-loader, you can refer to the example at examples/react-refresh, When using with swc-loader, simply replace builtin:swc-loader with swc-loader.babel-loader, you can refer to the example at examples/react-refresh-babel-loaderundefinedSpecifies which files should be processed by the React Refresh loader. This option is passed to the builtin:react-refresh-loader as the rule.test condition.
Works identically to Rspack's rule.test option.
new ReactRefreshPlugin({
test: [/\.jsx$/, /\.tsx$/],
});
/\.([cm]js|[jt]sx?|flow)$/iExplicitly includes files to be processed by the React Refresh loader. This option is passed to the builtin:react-refresh-loader as the rule.include condition.
Use this to limit processing to specific directories or file patterns.
Works identically to Rspack's rule.include option.
new ReactRefreshPlugin({
include: [/\.jsx$/, /\.tsx$/],
});
/node_modules/Exclude files from being processed by the plugin. The value is the same as the rule.exclude option in Rspack.
new ReactRefreshPlugin({
exclude: [/node_modules/, /some-other-module/],
});
undefinedCan be used to exclude certain resources from being processed by the plugin by the resource query. The value is the same as the rule.resourceQuery option in Rspack.
For example, to exclude all resources with the raw query, such as import rawTs from './ReactComponent.ts?raw';, use the following:
new ReactRefreshPlugin({
resourceQuery: { not: /raw/ },
});
booleanfalseWhether to force enable the plugin.
By default, the plugin will not be enabled in non-development environments. If you want to force enable the plugin, you can set this option to true.
new ReactRefreshPlugin({
forceEnable: true,
});
It is useful if you want to:
none mode without setting NODE_ENV.electron-prerender (WARNING: Proceed at your own risk).stringoutput.uniqueName || output.librarySets a namespace for the React Refresh runtime.
It is most useful when multiple instances of React Refresh is running together simultaneously.
boolean | OverlayOptionsfalseModify the behavior of the error overlay.
Checkout OverlayOptions type signature for more details.
new ReactRefreshPlugin({
overlay: true,
});
new ReactRefreshPlugin({
overlay: {
// ...
},
});
booleanfalseConfig the plugin whether trigger a full page reload when an unrecoverable runtime error is encountered.
Currently, only module factory undefined error is considered as unrecoverable runtime error.
new ReactRefreshPlugin({
reloadOnRuntimeErrors: true,
});
stringbuiltin:react-refresh-loaderBe default, the plugin uses builtin:react-refresh-loader loader implementation from Rspack in order ot inject
the React Refresh utilities into each module. reactRefreshLoader option allows to specify the loader, that implements
custom React Refresh instrumentation if needed.
new ReactRefreshPlugin({
reactRefreshLoader: 'my-advanced-react-refresh-loader',
});
Thanks to the react-refresh-webpack-plugin created by @pmmmwh, which inspires implement this plugin.
@rspack/plugin-react-refresh is MIT licensed.
FAQs
React refresh plugin for Rspack
The npm package @rspack/plugin-react-refresh receives a total of 422,164 weekly downloads. As such, @rspack/plugin-react-refresh popularity was classified as popular.
We found that @rspack/plugin-react-refresh demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.