Skip to main content
import { View, Button } from 'react-native';
import { useStytchMember, useStytchB2BClient } from '@stytch/react-native/b2b';

export const App = () => {
  const stytch = useStytchB2BClient();
  const { member, isInitialized } = useStytchMember();

  useEffect(() => {
    if (isInitialized && member) {
      // redirect to logged in experience
    }
  }, [isInitialized, member]);

  const authenticate = useCallback(() => {
    stytch.session.updateSession({
      session_token: 'a session token from your backend',
      session_jwt: 'a session JWT from your backend',
    });

    stytch.session.authenticate({ session_duration_minutes: 60 });
  }, [stytch]);

  return (
    <View>
      <Button title="Hydrate session" onPress={authenticate} />
    </View>
  );
};
Hydrate a front-end session with a member’s session tokens from your backend. If you log a member in with one of our backend SDKs, you can pass the resulting session_token and session_jwt to this method to prime the frontend SDK with a valid set of tokens. Then, make a Session Authenticate call to authenticate the session tokens and retrieve the user’s current session.

Parameters

options
object
required
An object containing the session tokens to update the front-end session.