useAuthViewState()
The useAuthViewState() hook reports when native authentication and Clerk-owned post-authentication steps are complete. Use it to determine when a non-dismissible root <AuthView /> can be replaced with authenticated content.
The hook waits for both the native authentication flow and the JavaScript session state. This keeps <AuthView /> mounted while it displays session tasks or biometric enrollment.
If native authentication-flow state isn't available, the hook falls back to the JavaScript authentication state. It considers the flow complete once authentication has loaded and the user is signed in.
- Name
isLoaded- Type
boolean- Description
Whether the JavaScript authentication state and any available native authentication-flow state have loaded.
- Name
isAuthFlowComplete- Type
boolean- Description
Whether authenticated content can replace the root
<AuthView />. In a native build, this requires a signed-in JavaScript session and a native authentication flow that has completed authentication and any Clerk-owned post-authentication steps.
How to use the useAuthViewState() hook
The following example demonstrates how to keep a required root <AuthView /> mounted until the native authentication flow is complete. If you render <AuthView /> in a dismissible modal instead, use its onDismiss callback to control the modal.
import { AuthView, useAuthViewState } from '@clerk/expo/native'
import { Redirect } from 'expo-router'
export default function SignInScreen() {
const { isLoaded, isAuthFlowComplete } = useAuthViewState()
if (!isLoaded) {
return null
}
if (isAuthFlowComplete) {
return <Redirect href="/(home)" />
}
return <AuthView isDismissible={false} />
}To learn how a prebuilt authentication flow can enroll a trusted device and sign in a returning user with biometrics, see the biometric sign-in guide.
Feedback
Last updated on