Guest Mode allows you to provision one or more wallets for a new user so they can start using your app without going through the sign-up process.
With Guest Mode enabled, you can offer an option for your users to get started with a guest account without signing up. When users eventually sign up, any previously created guest wallets will immediately be linked to their account.
Create Guest Wallets
Use the useCreateGuestWallets hook to create guest wallets programmatically:
import { useCreateGuestWallets } from "@getpara/react-native-wallet";
import { Button, Alert } from "react-native";
function GuestLoginButton() {
const { createGuestWallets, isPending, isError } = useCreateGuestWallets();
const onPressGuestLogin = () => {
createGuestWallets(undefined, {
onSuccess: (wallets) => {
console.log("Guest wallets created:", wallets);
},
onError: (error) => {
Alert.alert("Error", "Failed to create guest wallets");
console.error(error);
},
});
};
return (
<Button
title={isPending ? "Creating..." : "Continue as Guest"}
onPress={onPressGuestLogin}
disabled={isPending}
/>
);
}
Tracking Guest Wallet Creation
Monitor wallet creation status with the useCreateGuestWallets hook’s own state, or use a separate state variable for cross-component access:
import { useCreateGuestWallets } from "@getpara/react-native-wallet";
import { View, Text } from "react-native";
function GuestStatus() {
const { isPending, isError, data } = useCreateGuestWallets();
if (isPending) return <Text>Creating guest wallets...</Text>;
if (isError) return <Text>Error creating guest wallets</Text>;
if (data) return <Text>Ready! {data.length} wallet(s) created</Text>;
return null;
}
We recommend using getUserShare and setUserShare to save and restore the user share for a guest wallet, just as you would for a pregenerated wallet.
Limitations
Currently, guest wallets are prevented from buying or selling crypto through the integrated onramp providers. If a guest wallet is funded, you must be careful to maintain user access to the wallets to ensure no funds are lost.
We recommend using getUserShare and setUserShare to save and restore the user share for a guest wallet, just as you would for a pregenerated wallet.