> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Enroll auth factors for new devices

> Enroll user-controlled recovery auth factors and attach callbacks to wallet recovery events

Set user-controlled recovery on the embedded wallet, and to attach callbacks to the wallet's recovery events.

<View title="React" icon="react">
  To prompt users to enroll an auth factor for new devices for their wallet, use the `setWalletRecovery` method from the `useSetWalletRecovery` hook:

  ```tsx theme={"system"}
  setWalletRecovery: async () => Promise<void>
  ```

  When invoked, this method will open a modal where the user can enroll an auth factor for new devices from the options (password, iCloud, Google Drive) you configured in the Dashboard.

  ### Usage

  ```tsx theme={"system"}
  import {useSetWalletRecovery} from '@privy-io/react-auth';
  const {setWalletRecovery} = useSetWalletRecovery();
  ```

  ### Parameters

  This method takes no parameters.

  ### Returns

  This method returns a `Promise` that resolves if the user successfully enrolls an auth factor, and rejects if there is an error.

  ### Callbacks

  You can optionally register an onSuccess or onError callback on the useSetWalletRecovery hook.

  ### Usage

  ```tsx theme={"system"}
  const {setWalletRecovery} = useSetWalletRecovery({
      onSuccess: (params: {
          method: UserRecoveryMethod;
          wallet: Wallet;
      }) => {
          console.log('Successfully enrolled auth factor');
      },
      onError: (error) => {
          console.error('Failed to enroll auth factor with error ', error)
      }
  })
  ```

  <ParamField path="onSuccess" type="({method: UserRecoveryMethod, wallet: Wallet}) => void">
    Optional callback to run after a user successfully enrolls an auth factor.
  </ParamField>

  <ParamField path="onError" type="(error: string) => void">
    Optional callback to run after there is an error during wallet recovery.
  </ParamField>
</View>

<View title="React Native" icon="react">
  To prompt users to enroll an auth factor for new devices for their wallet, use the `setEmbeddedWalletRecovery` method from the `useSetWalletRecovery` hook:

  ```tsx theme={"system"}
  setEmbeddedWalletRecovery: async () => Promise<void>
  ```

  ### Usage

  ```tsx theme={"system"}
  import {useSetEmbeddedWalletRecovery} from '@privy-io/expo';
  const {setEmbeddedWalletRecovery} = useSetEmbeddedWalletRecovery();
  ```

  ### Parameters

  This method accepts an object as a parameter with the following fields.

  <ParamField path="recoveryMethod" type="'password' | 'google-drive' | 'icloud'" required>
    The recovery method (auth factor) to enroll for the wallet.
  </ParamField>

  <ParamField path="password" type="string">
    Password to set on the wallet. Only valid if `recoveryMethod` is `'password'`.
  </ParamField>

  ### Returns

  This method returns a `Promise` that resolves if the user successfully enrolls an auth factor, and rejects if there is an error.
</View>
