@prelude.so/react-native-auth-sdk/react. It wraps the imperative client described on the previous pages: a provider that owns the client and restores the session on launch, hooks that expose session state and actions, and gates that render the right subtree.
Set up the provider
Wrap your app inPreludeAuthProvider instead of creating a PreludeAuthClient yourself. The provider creates the client, calls refresh() silently on mount to restore a cached session, and disposes the client on unmount.
To react once when the launch restore settles (hide a native splash screen, pick the first route), pass
onRestored:
Hooks
stage is one of initializing, signedOut, awaitingOtp, or signedIn.
Hook actions never throw. A failure lands in that hook’s error and is cleared when the next action starts. pending is true while one of that hook’s actions is in flight, so an unrelated button is not disabled by it. useAuth().client is the underlying PreludeAuthClient for calls the hooks do not cover, such as listSessions or revokeSessions.
Session lifecycle
Access tokens are short-lived; the refresh token is the session itself. Both lifetimes are set on your application. Contact us to change them.
Try it
Try it
A complete app: splash on launch, OTP login when signed out, and a home screen with sign out. When the session can no longer be refreshed, the SDK moves back to the login screen on its own. Replace
app/index.tsx with:app/index.tsx