> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate with Passkey

> [card] Recommended: JavaScript SDK for React Native
>
> While this SDK is still supported, we recommend using newer [JavaScript SDK](https://docs.dynamic.xyz/docs/javascript/reference/react-native-quickstart.md), which is optimized for React Native, but also comes with a host of other benefits.

> [!NOTE]
>
> The user must have already signed in via another method (e.g. email/password, social, etc.) and added a passkey to their account before they can use it to sign in with.
>
> You can prompt a user to add a passkey to their account using your SDK's passkey registration method (see SDK-specific Tabs) or by directing them to the account security section in your app (the client/WebView flow).

## Console Configuration

Simply toggle on "Passkey" in [the Log in & User Profile section of the Dynamic Console](https://console.dynamic.xyz/dashboard/log-in-user-profile).

```ts React Native theme={"system"}
  import { dynamicClient } from '<path to client file>';

  // Primary sign-in with passkey (1FA)
  await dynamicClient.auth.passkey.signIn({
    relatedOriginRpId: 'example.com', // Optional, if you want to sign in from a related origin
  });

  // Register a new passkey for the signed-in user
  await dynamicClient.passkeys.register();

  // MFA authenticate using an existing passkey
  await dynamicClient.passkeys.authenticateMFA({
    relatedOriginRpId: 'example.com', // Optional, if you want to authenticate from a related origin
  });
```

> [!NOTE]
>
> `relatedOriginRpId` is the Relying Party ID (RP ID). The canonical form is a **bare hostname** such as `my.example.com`; a full origin like `https://my.example.com` is also accepted and resolves to the same RP ID. It must match the `rpId` the credential was registered under. See [Related Origin Requests](https://passkeys.dev/docs/advanced/related-origins/).

## Signing in with a passkey from a related domain

Passkeys are bound to the RP ID they were registered under, which is normally your domain. If your users registered passkeys on a different domain, for example a previous domain you are migrating away from, pass that domain as `relatedOriginRpId` so they can keep signing in with their existing passkeys instead of registering new ones.

```ts React Native theme={"system"}
  // Sign in with a passkey registered on a previous domain
  await dynamicClient.auth.passkey.signIn({
    relatedOriginRpId: 'old.example.com',
  });
```

Two conditions apply:

* The domain named by `relatedOriginRpId` must link the two origins by hosting `https://old.example.com/.well-known/webauthn` with your current domain in its `origins` list: `{ "origins": ["https://app.example.com"] }`.
* The related domain must also be covered by your app's platform configuration (webcredentials associated domains on iOS, asset links on Android). See the [React Native Passkey Setup guide](https://docs.dynamic.xyz/docs/react-native/reference/setup-passkey.md).

  > [!NOTE]
  >
  > React Native requires platform setup for passkeys. See the [React Native Passkey Setup guide](https://docs.dynamic.xyz/docs/react-native/reference/setup-passkey.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.