Skip to content

API reference > @kontsedal/olas-react > useRoot

useRoot() function ​

Resolve the root's public api from <OlasProvider>. Throws if called outside a provider — this catches the common "I forgot to wrap" mistake at the first hook call. See spec §20.10.

The return type is the root registered through Register. Without a registration it is unknown, and useRoot<Api>() names it per call, as an unchecked cast. For several roots, createOlasContext<Api>() gives each its own provider and a typed useRoot.

Signature:

typescript
export declare function useRoot<Api = RegisteredApi>(): Api;

Returns:

Api

Released under the MIT License.