Skip to main content

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 />Expo Icon 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.

Important

The native <AuthView /> is available only on iOS and Android. It requires a development build that includes a compatible version of @clerk/expo and doesn't work in Expo Go.

  • 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.

src/app/(auth)/sign-in.tsx
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

What did you think of this content?

Last updated on