<UnrealBridgeProvider>
Source: web/sdk/src/components/UnrealBridgeProvider.tsx
Root React provider that constructs a single BridgeManager instance and exposes it to every hook and component in this SDK via React Context. Mount it once, at the root of your app — every other public API in unreal-react-bridge assumes a <UnrealBridgeProvider> ancestor.
import { createRoot } from 'react-dom/client';
import { UnrealBridgeProvider } from 'unreal-react-bridge';
import App from './App';
createRoot(document.getElementById('root')!).render(
<UnrealBridgeProvider>
<App />
</UnrealBridgeProvider>,
);Props
The provider accepts every field of BridgeConfig plus children.
| Prop | Type | Default | Notes |
|---|---|---|---|
children | ReactNode | — | Required. Your application tree. |
debug | boolean | false | When true, the underlying BridgeManager logs connection state, sent payloads, and ready transitions to the browser console. |
TIP
There is no mock or autoSignalReady prop. The provider already handles the connect/ready handshake automatically by listening for the ue5-bridge-ready window event and invoking window.ue.bridge.onreactready() as soon as the bridge object is bound. See /guide/lifecycle for the full handshake.
Context value
Internally, the provider publishes the following shape (consumed by hooks):
interface BridgeContextValue {
bridge: BridgeManager;
isConnected: boolean;
isReady: boolean;
initialState: Record<string, unknown>;
}bridge— the singletonBridgeManagerfor this React tree.isConnected—trueoncewindow.ue.bridgeexists (Unreal completedBindUObject).isReady—trueonce Unreal'sOnReactReadylifecycle hook has fired.initialState— snapshot delivered viaue5-bridge-ready.detail.initialState. SeeuseInitialState.
You consume this value through hooks (useUnrealBridge, useUnrealEvent, etc.). Direct context access is not part of the public API.
Behavior
- The provider constructs the
BridgeManagerlazily inside auseRef, so it survives re-renders and StrictMode double-invocation. - It subscribes to the
ue5-bridge-readywindow event once on mount. When it fires, the provider re-readsbridge.getStatus()and re-renders consumers. - On unmount it calls
bridge.destroy(), which removes the window listener and clears every internal subscription.
Dev mode (running outside Unreal)
When you open your React app in a regular browser (e.g. vite dev on http://localhost:5173), window.ue.bridge is not defined. The provider still mounts; the bridge sits in the not connected state:
isConnectedandisReadystayfalse.useUnrealBridge().send(...)is a no-op that prints a single warning to the console.- All event subscriptions wire up as normal
window.addEventListenercalls — you can manuallywindow.dispatchEvent(new CustomEvent('player:hp', { detail: { value: 50 } }))from the browser devtools to drive your UI.
That graceful-degrade behavior is what makes hot reload usable; you can iterate UI in Chrome without launching the Editor. See /guide/dev-server for the full dev workflow.
WARNING
A single React tree must have exactly one <UnrealBridgeProvider>. Nesting providers creates two independent BridgeManager instances and will cause duplicate sends and dropped subscriptions.
See also
/reference/react-hooks—useUnrealBridge,useUnrealEvent,useUnrealState,useInitialState/reference/react-components—UnrealReadyGate,UnrealEvent,UnrealValue,UnrealDevPanel/guide/dev-server— running the React app outside Unreal/guide/lifecycle— connect / ready handshake