React Native advanced setup
In this guide, you'll find an overview and best practices for enabling advanced features and using built in functions for biometric authentication (passkeys) and step-up.
Passkeys authentication
Passkeys provide a seamless, passwordless login experience using WebAuthn and platform-level biometric authentication.
Prerequisites
- iOS Version: Ensure your project targets iOS 15 or later to support the necessary WebAuthn APIs.
- Android: Use Android SDK 26+.
- Frontegg SDK Version: Use Frontegg iOS SDK version 1.2.24 or later.
Android setup
- Open
android/build.gradle
. - Add the following Gradle dependencies under dependencies:
dependencies {
implementation 'androidx.browser:browser:1.8.0'
implementation 'com.frontegg.sdk:android:1.2.30'
}
- Inside the
android
block, add the following to set Java 8 compatibility:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
iOS setup
- Open your project in Xcode
- Go to your target settings
- Open the Signing & Capabilities tab
- Click the + Capability button and add Associated Domains
- Under Associated Domains, click the + and add:
webcredentials:your-domain.com
. For example, if your domain ishttps://example.com
, usewebcredentials:example.com
. - Enter your domain in the format:
webcredentials:[YOUR_DOMAIN]
. For example:webcredentials:example.com
. - Host a
.well-known/webauthn
JSON file on your domain server with the following structure:
{
"origins": [
"https://example.com",
"https://subdomain.example.com"
]
}
- Ensure the file is publicly accessible at:
https://example.com/.well-known/webauthn
. - Verify that your Associated Domains configuration works using Apple’s Associated Domains Validator.
Register passkeys
Use the registerPasskeys method to register a passkey for the current user:
import { registerPasskeys } from '@frontegg/react-native';
async function handleRegisterPasskeys() {
try {
await registerPasskeys();
console.log('Passkeys registered successfully');
} catch (error) {
console.error('Error registering passkeys:', error);
}
}
Login with passkeys
Use the loginWithPasskeys method to log in using passkeys:
import { loginWithPasskeys } from '@frontegg/react-native';
async function handleLoginWithPasskeys() {
try {
await loginWithPasskeys();
console.log('Passkeys login successful');
} catch (error) {
console.error('Error logging in with Passkeys:', error);
}
}