useGuestAuth
Create guest accounts that allow users to explore your app without committing to a specific authentication method.
Request
type Request = {
hook: 'useGuestAuth',
params: [options?: GuestHookOptions]
}
type GuestHookOptions = {
logoutOnError?: boolean
recoverWalletAutomatically?: boolean
onSuccess?: (data: GuestHookResult) => void
onError?: (error: import("@openfort/react-native").OpenfortError) => void
onSettled?: (data: GuestHookResult | undefined | null, error: import("@openfort/react-native").OpenfortError | null) => void
throwOnError?: boolean
}
Response
type Response = GuestAuthReturn
type GuestAuthReturn = GuestStatusFlags & {
signUpGuest(options?: GuestHookOptions): Promise<GuestHookResult>
}
type GuestStatusFlags = {
isLoading: boolean
isError: boolean
isSuccess: boolean
error?: import("@openfort/react-native").OpenfortError | null
}
type GuestHookResult = {
error?: import("@openfort/react-native").OpenfortError
user?: import("@openfort/openfort-js").AuthPlayerResponse
wallet?: import("@openfort/react-native").UserWallet
}
Example
import { useGuestAuth } from "@openfort/react-native"
function GuestCTA() {
const { signUpGuest, isLoading, isError, isSuccess, error } = useGuestAuth({
throwOnError: true,
onSuccess: () => {},
onError: () => {},
onSettled: () => {},
})
return (
<Button
title="Try as guest"
onPress={() => signUpGuest()}
disabled={isLoading}
/>
)
}