useSetup2fa hook initiates the 2FA setup flow, returning a QR code URI and secret that the user can add to their authenticator app. Follow with useEnable2fa to complete enrollment.
Hook for setting up two-factor authentication
useSetup2fa hook initiates the 2FA setup flow, returning a QR code URI and secret that the user can add to their authenticator app. Follow with useEnable2fa to complete enrollment.
import { useSetup2fa } from "@getpara/react-native-wallet";
import { useSetup2fa } from "@getpara/react-native-wallet";
import { View, Text, Button } from "react-native";
function Setup2faScreen() {
const { setup2faAsync, data, isPending } = useSetup2fa();
return (
<View>
{data && (
<View>
<Text selectable>{data.uri}</Text>
<Text>Secret: {data.secret}</Text>
</View>
)}
<Button title={isPending ? "Loading..." : "Set Up 2FA"} onPress={() => setup2faAsync()} disabled={isPending} />
</View>
);
}