Configure passkeys for Expo
Passkeys are a secure, passwordless authentication method that use biometrics and a physical device to authenticate users. This guide shows you how to configure passkeys for your Expo application.
Enable passkeys
To use passkeys, first enable the strategy in the Clerk Dashboard.
- In the Clerk Dashboard, navigate to the Email, Phone, Username page.
- In the Authentication strategies section, enable Passkeys.
Configure passkeys
Use the following tabs to configure your passkeys for iOS
or Android
.
Get your App ID Prefix and Bundle ID from Apple
To get your App ID Prefix and Bundle ID, follow these steps:
- Navigate to the Apple Developer dashboard.
- Under Certificates, IDs and Profiles, select Identifiers.
- In the top-right, select the dropdown and select App IDs.
- Select the App ID you want to configure passkeys for. You'll be redirect to the Review your App ID Configuration page.
- At the top of the page, you'll see your App ID Prefix and Bundle ID. Save these values somewhere secure.
Set up your associated domain file in the Clerk Dashboard
- In the Clerk Dashboard, navigate to the Native Applications page.
- Select the iOS tab.
- Select Add iOS App.
- Paste the App ID Prefix and Bundle ID that you copied in the previous step.
- Select Add App.
- On the right-side, save your Frontend API URL somewhere secure.
Update app.json
in your Expo app
- In your app's
app.json
file, under theios
object, add theassociatedDomains
property as shown in the following example. Replace<YOUR_FRONTEND_API_URL>
with the Frontend API URL value that you saved in the previous step.
{
"expo": {
//...existing properties
"plugins": [
[
"expo-build-properties",
{
"ios": {
"deploymentTarget": "16.0" // iOS Support passkeys from version iOS 16+
}
}
]
],
"ios": {
//...existing properties
"associatedDomains": [
"applinks:<YOUR_FRONTEND_API_URL>",
"webcredentials:<YOUR_FRONTEND_API_URL>"
]
}
}
}
Set up your Android app links in the Clerk Dashboard
- In the Clerk Dashboard, navigate to the Native Applications page.
- Select the Android tab.
- Select Add Android app.
- Fill out the form with the following information:
- The
namespace
(This guide uses the default value:android_app
) - Your Android app's package name
- The
SHA256 certificate fingerprints
. If you don't know where to find theSHA256 certificate fingerprints
, see the Expo docs.
- The
- After submitting the form, you can verify that your
assetlinks.json
file is properly associated with your app by using Google's Statement List Generator and Tester. - On the right-side, save your Frontend API URL somewhere secure.
Install expo-build-properties
in your Expo application
npm install expo-build-properties
yarn add expo-build-properties
pnpm add expo-build-properties
Update app.json
in your Expo application
- In your app's
app.json
file, underandroid
, add theintentFilters
property as shown in the following example. Replace<YOUR_FRONTEND_API_URL>
with the Frontend API URL value that you saved in the previous step.
{
"expo": {
"plugins": [["expo-build-properties"]],
"android": {
//...existing properties
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"data": [
{
"scheme": "https",
"host": "<YOUR_FRONTEND_API_URL>"
}
],
"category": ["BROWSABLE", "DEFAULT"]
}
]
}
}
}
Install @clerk/expo-passkeys
Run the following command to install the @clerk/expo-passkeys
package:
npm install @clerk/expo-passkeys
yarn add @clerk/expo-passkeys
pnpm add @clerk/expo-passkeys
Prebuild Expo project
Run the following command to prebuild your Expo project:
npx expo prebuild
Update your <ClerkProvider>
Pass the passkeys
object to the __experimental_passkeys
property of your <ClerkProvider>
component, as shown in the following example:
import { tokenCache } from '@/cache'
import { ClerkProvider, ClerkLoaded } from '@clerk/clerk-expo'
import { passkeys } from '@clerk/clerk-expo/passkeys'
import { Slot } from 'expo-router'
export default function RootLayout() {
const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!
if (!publishableKey) {
throw new Error('Add EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY in your .env')
}
return (
<ClerkProvider
tokenCache={tokenCache}
publishableKey={publishableKey}
__experimental_passkeys={passkeys}
>
<ClerkLoaded>
<Slot />
</ClerkLoaded>
</ClerkProvider>
)
}
Usage
To learn how to use passkeys in your Expo application, such as creating, deleting, and authenticating users with passkeys, see the custom flow guide.
Feedback
Last updated on