Skip to main content
import { useEffect, useState } from 'react';
import { View, Text } from 'react-native';
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const GetRecoveryCodes = () => {
  const stytch = useStytchB2BClient();
  const [codes, setCodes] = useState([]);

  const fetchRecoveryCodes = async () => {
    const response = await stytch.recoveryCodes.get({
      organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
      member_id: 'member-test-32fc5024-9c09-4da3-bd2e-c9698807585d',
    });
    setCodes(response.recovery_codes);
  };

  useEffect(() => {
    fetchRecoveryCodes();
  }, []);

  return (
    <View>
      <Text>Recovery Codes</Text>
      {codes.map((code, index) => (
        <Text key={index}>{code}</Text>
      ))}
    </View>
  );
};
recoveryCodes.get wraps the Get Recovery Codes API endpoint. Both the organization_id and member_id for this request will be inferred from the current session.

Response

recovery_codes
string[]
The recovery codes used to authenticate the member without an authenticator app.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.