dioxus-react-integration
DEPRECATED — This repository is moving to dx-react/integration. This repo will be archived once the migration is complete.
Compatibility: Currently tested with Dioxus 0.7.3
Serve React applications inside the Dioxus desktop webview with automatic IPC bridge injection, CSS/JS loading, and proper asset resolution.
Why React + Dioxus?
- Use React's Ecosystem — thousands of React libraries, Tailwind CSS, shadcn/ui, etc.
- Native Performance — Dioxus provides the native runtime and window management
- Seamless IPC — built-in bridge for Rust <-> React communication
- Single Binary — package your React app inside your Dioxus binary
- Cross-Platform — desktop, web, and mobile from one codebase
Features
ReactAppComponent — loads CSS, injects IPC bridge, mounts JS bundle with correct asset resolutionReactManifest— readsmetadata.jsonfrom your build output to discover hashed chunk filenames- Folder Assets — uses Dioxus
asset!()on the build output directory (symlink-friendly, no copying) <base href>Injection — automatically sets the document base so relative asset paths in JS resolve correctly- Asset Registry — dynamic asset loading system (optional feature)
Breaking Changes (v0.2.0)
ReactContainer has been removed. Use ReactApp instead:
// Before (v0.1.x):
ReactContainer
// After (v0.2.0):
ReactApp
Quick Start
Installation
[]
= "0.7"
= "0.2"
= "0.2"
= "1.0"
Usage
use *;
use *;
use Duration;
/// Folder asset pointing to the React build output
const REACT_DIR: Asset = asset!;
Changelog
v0.2.2
- Updated: Depends on
deckyfx-dioxus-ipc-bridgev0.2.1 which fixes method-based route matching (GET and POST on the same path now work correctly).
v0.2.1
- Initial v0.2 patch release.
How It Works
Build Pipeline
react-app/
├── src/ ← React source (TypeScript, Tailwind, etc.)
└── dist/ ← Bun/bundler output (hashed chunks)
├── chunk-xxx.js
├── chunk-yyy.css
├── logo-zzz.svg
└── metadata.json ← generated post-build
assets/
└── react → ../react-app/dist ← symlink (copy on Windows)
- Build React app with any bundler (Bun, Vite, etc.)
- Post-build script generates
metadata.jsonlisting the chunk filenames - Symlink
assets/reactto the build output directory - Dioxus reads the folder via
asset!("/assets/react")and the manifest viainclude_str!
What ReactApp Does
The component handles the full lifecycle:
<base href>— injects a base tag so relative URLs in JS (like./logo.svg) resolve to the asset folder- Stylesheets — loads all CSS files listed in the manifest
- IPC bridge — injects the bridge initialization script before React loads
- Mount point — creates the
<div id="root">where React mounts - JS bundles — loads all script files listed in the manifest
Asset Resolution
Dioxus desktop serves the document at dioxus://index.html/ but assets live at /assets/react/. The <base href> tag bridges this gap:
| Reference in JS | Without <base> |
With <base href="/assets/react/"> |
|---|---|---|
"./logo.svg" |
/logo.svg (404) |
/assets/react/logo.svg (works) |
"./chunk.css" |
/chunk.css (404) |
/assets/react/chunk.css (works) |
CSS url() references already resolve correctly (relative to the CSS file), so they work regardless.
API Reference
ReactApp Component
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
dir |
Asset |
Yes | — | Folder asset from asset!("/assets/react") |
manifest |
ReactManifest |
Yes | — | Build manifest with chunk filenames |
bridge |
Option<IpcBridge> |
No | None |
IPC bridge (auto-injects script) |
mount_id |
String |
No | "root" |
DOM element ID for React mount |
ReactManifest
let manifest = from_json.expect;
Expected JSON format:
Optional Features
asset-registry— dynamic asset loading system viaAssetRegistry
Platform Support
| Platform | Status | Notes |
|---|---|---|
| Desktop (Windows/macOS/Linux) | Fully Supported | Native webview |
| Web (WASM) | Fully Supported | WASM + JavaScript |
| Mobile (iOS/Android) | Fully Supported | Native webview |
Examples
See dioxus-react-example for a complete working app with IPC routes, event streaming, Tailwind CSS, and shadcn/ui components.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Related
- deckyfx/dioxus-react-example - Complete working example app
- deckyfx/dioxus-ipc-bridge - Core IPC bridge library
- deckyfx/dioxus-ipc-bridge-macros - Proc macros for route handlers
- deckyfx/dioxus-react-bridge - React hooks and components for IPC
- Dioxus - Rust GUI framework
- React - JavaScript UI library