Skip to content

Documentation / expo / PrivyAuthGuard

Function: PrivyAuthGuard()

PrivyAuthGuard(__namedParameters): Element

This component is used to simplify protecting routes based on the user's authentication status, and the Privy SDK's readiness.

Parameters

__namedParameters: PropsWithChildren<PrivyAuthGuardProps>

Returns

Element

Example

ts
// This is a basic setup using `expo-router`
<PrivyAuthGuard
 loading={<SplashScreen />}
 unauthenticated={<Redirect href="/sign-in" />}
>
  <Stack />
</PrivyAuthGuard>

Example

ts
// This is a basic setup using `react-navigation`
<Stack.Navigator>
  <PrivyAuthGuard
   loading={<SplashScreen />}
   unauthenticated={
     <Stack.Group>
       <Stack.Screen name="Sign In" component={SignInScreen} />
       ...
     </Stack.Group>
   }
  >
    <Stack.Group>
      <Stack.Screen name="Home" component={HomeScreen} />
      ...
    </Stack.Group>
  </PrivyAuthGuard>