Skip to content
Torii docs

useRuntimeStatus

useRuntimeStatus() reports the load lifecycle of the SDK runtime: the UI primitives and their CSS, delivered from the CDN.

  • 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;
}
NameTypeDescription
statusRuntimeLoadStatus'loading' until the CDN runtime resolves, then 'ready' or 'error'. During SSR it is a stable 'loading'.
errorError | nullThe load error when status === 'error', otherwise null.
retry() => voidRe-attempt a failed load. No-op while loading or once ready.
import type {
UseRuntimeStatusReturn,
RuntimeLoadStatus,
} from '@torii-js/torii-react';