useRuntimeStatus
useRuntimeStatus() reports the load lifecycle of the SDK runtime: the UI
primitives and their CSS, delivered from the CDN.
When to use it
Section titled “When to use it”- Show a spinner or a retry button while the CDN runtime is in flight.
- Surface a load failure to the user (the SDK shows nothing by default).
The <ToriiLoading> / <ToriiLoaded> / <ToriiFailed>
control components cover the common cases declaratively; reach for this hook
when you need fully custom logic.
import { useRuntimeStatus } from '@torii-js/torii-react';
function RuntimeGate({ children }) { const { status, error, retry } = useRuntimeStatus();
if (status === 'loading') return <Spinner />; if (status === 'error') return ( <div role="alert"> Failed to load: {error?.message} <button onClick={retry}>Retry</button> </div> );
return children;}Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
status | RuntimeLoadStatus | 'loading' until the CDN runtime resolves, then 'ready' or 'error'. During SSR it is a stable 'loading'. |
error | Error | null | The load error when status === 'error', otherwise null. |
retry | () => void | Re-attempt a failed load. No-op while loading or once ready. |
TypeScript
Section titled “TypeScript”import type { UseRuntimeStatusReturn, RuntimeLoadStatus,} from '@torii-js/torii-react';