Skip to content

Commit 0048bd1

Browse files
committed
docs: add a note on using react refresh plugin in backend integration guide
1 parent f08a63e commit 0048bd1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/backend-integration.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ If you want to serve the HTML using a traditional backend (e.g. Rails, Laravel)
3535

3636
Also make sure the server is configured to serve static assets in the Vite working directory, otherwise assets such as images won't be loaded properly.
3737

38+
Note if you are using React with `@vitejs/plugin-react-refresh`, you'll also need to add this, since the plugin is not able to modify the HTML you are serving:
39+
40+
```html
41+
<script type="module">
42+
import RefreshRuntime from "/@react-refresh"
43+
RefreshRuntime.injectIntoGlobalHook(window) window.$RefreshReg$ = () => {}
44+
window.$RefreshSig$ = () => (type) => type
45+
window.__vite_plugin_react_preamble_installed__ = true
46+
</script>
47+
```
48+
3849
3. For production: after running `vite build`, a `manifest.json` file will be generated alongside other asset files. An example manifest file looks like this:
3950

4051
```json

0 commit comments

Comments
 (0)