|
| 1 | +--- |
| 2 | +title: Configure passkeys for Expo |
| 3 | +description: Learn how to configure passkeys for your Expo application. |
| 4 | +sdk: expo |
| 5 | +--- |
| 6 | + |
| 7 | +[Passkeys](/docs/guides/configure/auth-strategies/sign-up-sign-in-options#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. |
| 8 | + |
| 9 | +> [!WARNING] |
| 10 | +> This API is available only for [`@clerk/clerk-expo >=2.2.0`](/docs/guides/development/upgrading/upgrade-guides/expo-v2). |
| 11 | +
|
| 12 | +<Steps> |
| 13 | + ## Enable passkeys |
| 14 | + |
| 15 | + To use passkeys, first enable the strategy in the [Clerk Dashboard](https://dashboard.clerk.com/~/user-authentication/user-and-authentication?user_auth_tab=passkeys). |
| 16 | + |
| 17 | + ## Configure passkeys |
| 18 | + |
| 19 | + Use the following tabs to configure your passkeys for `iOS` or `Android`. |
| 20 | + |
| 21 | + <Tabs items={['iOS', 'Android']}> |
| 22 | + <Tab> |
| 23 | + > [!WARNING] |
| 24 | + > iOS supports passkeys from version iOS 16+ |
| 25 | + > |
| 26 | + > This library includes native code and will not work when running Expo Go. Instead, use a development build by running `npx expo run:ios`. |
| 27 | +
|
| 28 | + ### Get your App ID Prefix and Bundle ID from Apple |
| 29 | + |
| 30 | + To get your **App ID Prefix** and **Bundle ID**, follow these steps: |
| 31 | + |
| 32 | + 1. Navigate to the [Apple Developer dashboard](https://developer.apple.com/account). |
| 33 | + 1. Under **Certificates, IDs and Profiles**, select [**Identifiers**](https://developer.apple.com/account/resources/identifiers/list). |
| 34 | + 1. In the top-right, select the dropdown and select **App IDs**. |
| 35 | + 1. Select the **App ID** you want to configure passkeys for. You'll be redirect to the **Review your App ID Configuration** page. |
| 36 | + 1. At the top of the page, you'll see your **App ID Prefix** and **Bundle ID**. Save these values somewhere secure. |
| 37 | + |
| 38 | + ### Set up your associated domain file in the Clerk Dashboard |
| 39 | + |
| 40 | + 1. In the Clerk Dashboard, navigate to the [**Native Applications**](https://dashboard.clerk.com/last-active?path=user-authentication/native-applications) page. |
| 41 | + 1. Select the **iOS** tab. |
| 42 | + 1. Select **Add iOS App**. |
| 43 | + 1. Paste the **App ID Prefix** and **Bundle ID** that you copied in the previous step. |
| 44 | + 1. Select **Add App**. |
| 45 | + 1. On the right-side, save your **Frontend API URL** somewhere secure. |
| 46 | + |
| 47 | + ### Update `app.json` in your Expo app |
| 48 | + |
| 49 | + 1. In your app's `app.json` file, under the `ios` object, add the `associatedDomains` 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. |
| 50 | + |
| 51 | + ```json {{ filename: 'app.json', mark: [[5, 12], [14, 20]] }} |
| 52 | + { |
| 53 | + "expo": { |
| 54 | + //...existing properties |
| 55 | + "plugins": [ |
| 56 | + [ |
| 57 | + "expo-build-properties", |
| 58 | + { |
| 59 | + "ios": { |
| 60 | + "deploymentTarget": "16.0" // iOS Support passkeys from version iOS 16+ |
| 61 | + } |
| 62 | + } |
| 63 | + ] |
| 64 | + ], |
| 65 | + "ios": { |
| 66 | + //...existing properties |
| 67 | + "associatedDomains": [ |
| 68 | + "applinks:<YOUR_FRONTEND_API_URL>", |
| 69 | + "webcredentials:<YOUR_FRONTEND_API_URL>" |
| 70 | + ] |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + ``` |
| 75 | + </Tab> |
| 76 | + |
| 77 | + <Tab> |
| 78 | + > [!WARNING] |
| 79 | + > Android supports passkeys from version 9+. Passkeys will not work with Android emulators. You must use a physical device. |
| 80 | + > |
| 81 | + > This library includes native code and [will not work when running Expo Go](https://docs.expo.dev/workflow/customizing/#using-libraries-that-include-native-code). Instead, use a development build by running `npx expo run:android`. |
| 82 | +
|
| 83 | + ### Set up your Android app links in the Clerk Dashboard |
| 84 | + |
| 85 | + 1. In the Clerk Dashboard, navigate to the [**Native Applications**](https://dashboard.clerk.com/last-active?path=user-authentication/native-applications) page. |
| 86 | + 1. Select the **Android** tab. |
| 87 | + 1. Select **Add Android app**. |
| 88 | + 1. Fill out the form with the following information: |
| 89 | + - The `namespace` (This guide uses the default value: `android_app`) |
| 90 | + - Your Android app's package name |
| 91 | + - The `SHA256 certificate fingerprints`. If you don't know where to find the `SHA256 certificate fingerprints`, see the [Expo docs](https://docs.expo.dev/linking/android-app-links/#create-assetlinksjson-file). |
| 92 | + 1. 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**](https://developers.google.com/digital-asset-links/tools/generator). |
| 93 | + 1. On the right-side, save your **Frontend API URL** somewhere secure. |
| 94 | + |
| 95 | + ### Install `expo-build-properties` in your Expo application |
| 96 | + |
| 97 | + ```npm |
| 98 | + npm install expo-build-properties |
| 99 | + ``` |
| 100 | + |
| 101 | + ### Update `app.json` in your Expo application |
| 102 | + |
| 103 | + 1. In your app's `app.json` file, under `android`, add the `intentFilters` 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. |
| 104 | + |
| 105 | + ```json {{ filename: 'app.json', mark: [[3, 6], [10, 22]] }} |
| 106 | + { |
| 107 | + "expo": { |
| 108 | + "plugins": [["expo-build-properties"]], |
| 109 | + "android": { |
| 110 | + //...existing properties |
| 111 | + "intentFilters": [ |
| 112 | + { |
| 113 | + "action": "VIEW", |
| 114 | + "autoVerify": true, |
| 115 | + "data": [ |
| 116 | + { |
| 117 | + "scheme": "https", |
| 118 | + "host": "<YOUR_FRONTEND_API_URL>" |
| 119 | + } |
| 120 | + ], |
| 121 | + "category": ["BROWSABLE", "DEFAULT"] |
| 122 | + } |
| 123 | + ] |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + ``` |
| 128 | + </Tab> |
| 129 | + </Tabs> |
| 130 | + |
| 131 | + ## Install `@clerk/expo-passkeys` |
| 132 | + |
| 133 | + Run the following command to install the `@clerk/expo-passkeys` package: |
| 134 | + |
| 135 | + ```npm |
| 136 | + npm install @clerk/expo-passkeys |
| 137 | + ``` |
| 138 | + |
| 139 | + ## Prebuild Expo project |
| 140 | + |
| 141 | + Run the following command to prebuild your Expo project: |
| 142 | + |
| 143 | + ```bash {{ filename: 'terminal' }} |
| 144 | + npx expo prebuild |
| 145 | + ``` |
| 146 | + |
| 147 | + ## Update your `<ClerkProvider>` |
| 148 | + |
| 149 | + Pass the `passkeys` object to the `__experimental_passkeys` property of your `<ClerkProvider>` component, as shown in the following example: |
| 150 | + |
| 151 | + ```tsx {{ filename: 'app/_layout.tsx', mark: [4, 11] }} |
| 152 | + import { ClerkProvider } from '@clerk/clerk-expo' |
| 153 | + import { Slot } from 'expo-router' |
| 154 | + import { tokenCache } from '@clerk/clerk-expo/token-cache' |
| 155 | + import { passkeys } from '@clerk/clerk-expo/passkeys' |
| 156 | + |
| 157 | + export default function RootLayout() { |
| 158 | + return ( |
| 159 | + <ClerkProvider |
| 160 | + tokenCache={tokenCache} |
| 161 | + publishableKey={publishableKey} |
| 162 | + __experimental_passkeys={passkeys} |
| 163 | + > |
| 164 | + <Slot /> |
| 165 | + </ClerkProvider> |
| 166 | + ) |
| 167 | + } |
| 168 | + ``` |
| 169 | +</Steps> |
| 170 | + |
| 171 | +## Usage |
| 172 | + |
| 173 | +To learn how to use passkeys in your Expo application, such as creating, deleting, and authenticating users with passkeys, see the [custom flow guide](/docs/guides/development/custom-flows/authentication/passkeys). |
0 commit comments