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>;};
{ "session": { ... }, "fromCache": false}
{ "session": null, "fromCache": false}
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>;};
{ "session": { ... }, "fromCache": false}
{ "session": null, "fromCache": false}
Hooks
useStytchSession
Access the current session state using the Stytch React Native SDK
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>;};
{ "session": { ... }, "fromCache": false}
{ "session": null, "fromCache": false}
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>;};
{ "session": { ... }, "fromCache": false}
{ "session": null, "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.
Return Value
object | null
The current Session.
Show properties
string
A unique identifier for a specific Session.
string
The unique ID of the affected User.
array[objects]
An array of different authentication factors that comprise a Session.
string
The timestamp when the Session was created. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.
string
The timestamp when the Session was last accessed. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.
string
The timestamp when the Session expires. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.
object
Provided attributes help with fraud detection.
Show properties
string
The IP address of the user.
string
The user agent of the User.
map
The custom claims map for a Session. Claims can be added to a session during a Sessions authenticate call.
array[string]
A list of the roles associated with the session.
boolean
Whether the Session data is from persistent storage.
Assistant
Responses are generated using AI and may contain mistakes.