import { Text } from 'react-native';import { useStytchSession } from '@stytch/react-native';export const SessionInfo = () => { const { session } = useStytchSession(); return session ? <Text>Session ID: {session.session_id}</Text> : <Text>No active session</Text>;};
Copy
Ask AI
{ "session": { ... }, "fromCache": false}
Report incorrect code
Copy
Ask AI
import { Text } from 'react-native';import { useStytchSession } from '@stytch/react-native';export const SessionInfo = () => { const { session } = useStytchSession(); return session ? <Text>Session ID: {session.session_id}</Text> : <Text>No active session</Text>;};
Report incorrect code
Copy
Ask AI
{ "session": { ... }, "fromCache": false}
Hooks
useStytchSession
Access the current session state using the Stytch React Native SDK
Copy
Ask AI
import { Text } from 'react-native';import { useStytchSession } from '@stytch/react-native';export const SessionInfo = () => { const { session } = useStytchSession(); return session ? <Text>Session ID: {session.session_id}</Text> : <Text>No active session</Text>;};
Copy
Ask AI
{ "session": { ... }, "fromCache": false}
To get the active Session for the currently signed in User, use the useStytchSession hook.If no User is signed in, the returned value will be null.In non-React environments, use the session.getSync method to get the Session.