If a valid biometric registration exists, this method confirms the current device owner via the device's built-in biometric reader and returns a session object by either starting a new session or adding a biometric factor to an existing session.
Authenticate
Method parameters
Configuration options.
The text rendered when raising the biometric prompt
Set the session lifetime to be this many minutes from now. This will return both an opaque session_token and session_jwt for this session, which will automatically be stored either in the browser cookies if you're using our JavaScript SDK, or in the iOS Keychain/ Android SharedPreferences if you're using one of our mobile SDKs. The session_jwt will have a fixed lifetime of five minutes regardless of the underlying session duration, and will be automatically refreshed by the SDK in the background over time.
This value must be a minimum of 5 and may not exceed the maximum session duration minutes value set in the Frontend SDK page of the Stytch Dashboard.
A successful authentication will continue to extend the session this many minutes.
The text rendered on the cancel button when raising the biometric prompt. Defaults to "Cancel".
Allows user to enter their device credentials (e.g. PIN code) as a fallback for failed biometric authentication. If this is set to false on registration, authentication will not be allowed to enable fallback to device credentials.
import React, { useCallback } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { useStytch } from '@stytch/react-native';
export const Authenticate = () => {
const stytch = useStytch();
const authenticateBiometrics = useCallback(() => {
stytch.biometrics.authenticate({
prompt: 'Login with Biometrics',
sessionDurationMinutes: 60,
});
}, [stytch]);
return (
<View>
<TouchableOpacity onPress={authenticateBiometrics}>
<Text>Authenticate with Biometrics</Text>
</TouchableOpacity>
</View>
);
};