useSubscribeToJwtAuthWithFlag
hook to subscribe the Privy SDK to your auth provider’s
state.PrivyProvider
, and your custom auth provider, call the
useSubscribeToJwtAuthWithFlag
hook to subscribe the Privy SDK to your auth provider’s state.MyStateSyncComponent
component) should be mounted throughout the
lifetime of your app to ensure state is kept in sync.enabled
flag to false
in
the hook configuration.enabled
flag to false
will disable the external auth provider and will stop
Privy from attempting to synchronize its state with the external auth provider regardless of the
value of the isAuthenticated
flag, until enabled
is set to true
again.isAuthenticated
flag.isAuthenticated
flag, you can use the useSyncJwtBasedAuthState
hook to subscribe to
the auth provider’s state via state listeners.Let’s say the library for your auth provider exports an authStore
object that holds state.subscribe
method that takes a callback, and invokes it every time the
auth state changes, most importantly when the user either logs in or out.getState
method that returns the current state, which we can use to
get the current JWT token whenever necessary.useSyncJwtBasedAuthState
hook, we can link Privy to the auth provider’s state store
by using those two methods.login
method (from useLogin
or usePrivy
). Instead, call the login method of your custom provider, and the Privy SDK will automatically synchronize its state.