> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# `useOpenfort`

Access SDK initialization state and errors. Gate your first screen on it so nothing calls an authentication or wallet hook while `OpenfortProvider` is still creating the client and restoring the stored session.

## Usage

```tsx
import { useOpenfort } from '@openfort/react-native';
import { ActivityIndicator, Text } from 'react-native';

function App() {
  const { isReady, error } = useOpenfort();

  if (error) return <Text>{`Failed to initialize: ${error.message}`}</Text>;
  if (!isReady) return <ActivityIndicator size="large" />;

  return <HomeScreen />;
}
```

## Return type

```ts
type UseOpenfort = {
  isReady: boolean       // SDK finished initializing
  error: Error | null    // Initialization error, if any
}
```

| Property | Type | Description |
|----------|------|-------------|
| `isReady` | `boolean` | `true` once the provider has created the Openfort client and the initial session restore has settled. |
| `error` | `Error \| null` | Initialization error surfaced by the provider. `null` when initialization succeeded. |

## What `isReady` covers

`isReady` reports SDK initialization, not authentication: it also turns `true` for a signed-out user, as soon as the provider confirms there is no session to restore. Read `isAuthenticated` from [`useUser`](https://www.openfort.io/docs/products/embedded-wallet/react-native/hooks/useUser) to branch on auth state.

It is not a wallet-ready signal either. The provider mounts the hidden WebView that the embedded wallet communicates through only after `isReady` turns `true`, so wallet work starts after this point. Track wallet progress with the `status` field of [`useEmbeddedEthereumWallet`](https://www.openfort.io/docs/products/embedded-wallet/react-native/hooks/useEmbeddedEthereumWallet) or [`useEmbeddedSolanaWallet`](https://www.openfort.io/docs/products/embedded-wallet/react-native/hooks/useEmbeddedSolanaWallet), and see [Wallet lifecycle](https://www.openfort.io/docs/products/embedded-wallet/wallet-lifecycle) for the underlying states.

## Errors during initialization

Configuration mistakes throw from the provider instead of arriving through `error`, so wrap the provider in a React error boundary to catch them:

* A missing `publishableKey` or `walletConfig.shieldPublishableKey` throws `[Openfort SDK] Missing required .env variables: ...` while `OpenfortProvider` renders.
* Mounting a second `OpenfortProvider` anywhere in the tree throws `Found multiple instances of OpenfortProvider`.
* Calling an Openfort hook outside the provider throws `useOpenfortContext must be used within a OpenfortProvider`.

:::info
[`AuthBoundary`](https://www.openfort.io/docs/products/embedded-wallet/react-native/components/auth-boundary) wraps this hook and `useUser` behind a declarative API: pass `loading`, `unauthenticated`, and `error` elements and it picks the branch. Use `useOpenfort` directly when you need the raw flags, for example to keep a splash screen mounted or to report the error yourself.
:::

## Related

* [`useUser`](https://www.openfort.io/docs/products/embedded-wallet/react-native/hooks/useUser) — Current user, auth status, and access token
* [`useOpenfortClient`](https://www.openfort.io/docs/products/embedded-wallet/react-native/hooks/useOpenfortClient) — The client instance the provider created
* [Components](https://www.openfort.io/docs/products/embedded-wallet/react-native/components) — `OpenfortProvider` props and wallet configuration
