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
Usage
Enabling React Fast Refresh functionality primarily involves two aspects: code injection and code transformation.
Code injection will inject some code from the react-refresh package, as well as some custom runtime code, all of which are integrated in this plugin and can be injected through.
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.
Example
For usage with 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.
The npm package @rspack/plugin-react-refresh receives a total of 826,288 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.
Package last updated on 10 Aug 2024
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.
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
By Lauren Valencia, Kirill Boychenko - Sep 17, 2025
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.
By Kush Pandya, Peter van der Zee, Olivia Brown, Socket Research Team - Sep 16, 2025