Skip to main content
The useEnable2fa hook completes 2FA enrollment by verifying the code from the user’s authenticator app. Call it after useSetup2fa has returned the QR code and the user has scanned it.

Import

import { useEnable2fa } from "@getpara/react-native-wallet";

Usage

import { useEnable2fa } from "@getpara/react-native-wallet";
import { useState } from "react";
import { View, TextInput, Button } from "react-native";

function Enable2faScreen() {
  const [code, setCode] = useState("");
  const { enable2faAsync, isPending } = useEnable2fa();

  const handleEnable = async () => {
    try {
      await enable2faAsync({ verificationCode: code });
    } catch (err) {
      console.error(err);
    }
  };

  return (
    <View>
      <TextInput value={code} onChangeText={setCode} placeholder="Enter code from app" keyboardType="number-pad" />
      <Button title={isPending ? "Enabling..." : "Enable 2FA"} onPress={handleEnable} disabled={isPending} />
    </View>
  );
}