Skip to main content
import React, { useCallback, useEffect, useState } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { useStytch, useStytchSession } from '@stytch/react-native';

export const Register = () => {
  const stytch = useStytch();
  const { session } = useStytchSession();

  const [isKeystoreAvailable, setIsKeystoreAvailable] = useState(false);
  useEffect(() => {
    if (stytch) {
      stytch.biometrics.isKeystoreAvailable().then(setIsKeystoreAvailable);
    }
  }, [stytch]);

  const registerBiometrics = useCallback(() => {
    if (session) {
      stytch.biometrics.register({
        prompt: 'Register Your Biometric Factor',
      });
    }
  }, [session, stytch.biometrics]);

  return isKeystoreAvailable ? (
    <View>
      <TouchableOpacity onPress={registerBiometrics}>
        <Text>Register with Biometrics</Text>
      </TouchableOpacity>
    </View>
  ) : null;
};
Call this method to check if the Keystore is available on the device. This will always return true for iOS devices. A percentage of Android devices will return false. To learn more about the implications of the Android Keystore being unavailable, read our Android Keystore resource.

Response

available
boolean
Whether the Keystore is available on the device.
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.