useUser
Access the current authenticated user and account information.
Request
type Request = {
hook: 'useUser',
params: []
}
Response
type Response = UseUserReturn
type UseUserReturn = {
user: import("@openfort/openfort-js").AuthPlayerResponse | null
isAuthenticated: boolean
getAccessToken(): Promise<string | null>
}
Example
import { useUser } from "@openfort/react-native"
function ProfileScreen() {
const { user, isAuthenticated, getAccessToken } = useUser()
if (!isAuthenticated) return <SignInCard />
return (
<View>
<Text>{user?.player?.name}</Text>
<Button title="Refresh token" onPress={() => getAccessToken()} />
</View>
)
}