useKnockAuthState
The useKnockAuthState hook subscribes to a Knock client's authentication state, re-rendering your component when the authenticated user changes. It's backed by the subscribable authStore on the client, so it stays correct even when the client is re-authenticated in place — for example, when you toggle the enabled prop on KnockProvider.
Parameters
#This hook accepts a single argument:
An authenticated Knock client, such as the instance returned by the useKnockClient hook.
Returns
#Returns a KnockAuthState object describing the client's current authentication.
Whether a user is authenticated to the client.
The ID of the authenticated user, or undefined when no user is authenticated.
The user token in use for the authenticated user, when one was provided.
Example
#The following example reads the authentication state to render different UI while a user authenticates. It pairs well with the enabled prop on KnockProvider, which flips the client between unauthenticated and authenticated as the identity loads.