Skip to content

Waiting for Privy to be ready

When the PrivyProvider is first rendered on your page, the Privy SDK will initialize some state about the current user. This might include checking if the user has a wallet connected, refreshing expired auth tokens, fetching up-to-date user data, etc.

As a consequence, it's important to wait until the PrivyProvider has finished initializing before you consume Privy's state and interfaces, to ensure that the state you consume is accurate and not stale.

To determine whether the Privy SDK has fully initialized on your page, check the ready Boolean returned by the usePrivy hook. When ready is true, Privy has completed initialization, and your app can consume Privy's state and interfaces.

tsx
const {ready} = usePrivy();

Concretely, you should wait for ready to be true before using any other methods or variables returned by the usePrivy hook.