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

# ユーザーのパスキー管理

> Auth0 My Account API を使用して、ユーザーが自身の WebAuthn パスキーを登録・取り消しできるカード形式の UI をレンダリングします。

> [!WARNING]
>
> **Auth0 Universal Components機能は現在、[Beta](/docs/docs/troubleshoot/product-lifecycle/product-release-stages)です。**
>
> 参加をご希望の場合は、Auth0 Supportまでお問い合わせください。
>
> この機能を使用することにより、Oktaの該当する無料トライアル規約および[Master Subscription Agreement](https://www.okta.com/legal)に同意したものとみなされます。

`UserPasskeyManagement` コンポーネントを使用すると、ユーザーは [My Account API](/docs/docs/ja-jp/manage-users/my-account-api) を使用して、カード形式の単一インターフェースで[パスキー](/docs/docs/ja-jp/authenticate/database-connections/passkeys)を登録・取り消しできます。レンダリングにプロップスは必要ありません。
このコンポーネントには、登録済みのパスキーのリスト、新しいパスキーを追加するボタン、取り消しオプションが表示されます。

![登録済みのパスキーを表示するユーザーパスキー管理コンポーネント](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/universal-components/my-account/web/user-passkey-management-light.png)

## 前提条件

パスキーのサポートを有効にするには、次の要件を満たす必要があります。

* **Auth0 テナントにカスタムドメインを設定する**。パスキーを使用するには、[カスタムドメイン](/docs/docs/ja-jp/customize/custom-domains)が必要です。

* **Auth0 のデータベース接続でパスキーを有効にする**。Auth0 テナントでパスキーを有効にする方法については、[パスキーを設定する](/docs/docs/ja-jp/authenticate/database-connections/passkeys/configure-passkey-policy#configure-passkeys)を参照してください。

* **オリジンを一致させる**。Relying Party ID は、アプリケーションのドメインと同一であるか、その登録可能な親ドメインである必要があります。詳細については、[パスキーの Relying Party ID](/docs/docs/ja-jp/authenticate/database-connections/passkeys#relying-party-id-for-passkeys)を参照してください。

* **アプリケーションで HTTPS を使用していることを確認する**。WebAuthn では、アプリケーションが HTTPS 経由で提供される必要があります。

* **アプリケーションに Universal Components をインストールして設定する**。Universal Components のインストールと設定については、[アカウントセキュリティ UI を構築する](/docs/docs/ja-jp/get-started/universal-components/web/components/my-account-overview#prerequisites)を参照してください。

## アプリケーションを設定する

フレームワークを選択して、環境変数とUniversal Componentsを設定します。

> [tab] React（SPA）
>
> ## コンポーネントをインストールする
>
> ```bash pnpm wrap lines theme={null}
> pnpm add @auth0/universal-components-react react-hook-form @tanstack/react-query
> ```
>
> ```bash npm wrap lines theme={null}
> npm install @auth0/universal-components-react react-hook-form @tanstack/react-query
> ```
>
> `react-hook-form` と `@tanstack/react-query` はピア依存関係です。このコマンドにより、共有ユーティリティおよび Auth0 連携に必要な `@auth0/universal-components-core` もインストールされます。
>
> ## はじめに
>
> ```tsx wrap lines theme={null}
> import { UserPasskeyManagement } from "@auth0/universal-components-react";
>
> export function SecurityPage() {
>   return <UserPasskeyManagement />;
> }
> ```
>
> * コンポーネントはフレームワークにかかわらず、常にルートエントリ `@auth0/universal-components-react` からインポートします。
>
> * フレームワーク固有のサブパスを使用するのは `Auth0ComponentProvider` コンポーネントだけです。React アプリケーションには `/spa`、Next.js アプリケーションには `/rwa` を使用します。
>
> > [accordion] 連携の完全な例
> >
> > ```tsx wrap lines theme={null}
> > import React from "react";
> > import { UserPasskeyManagement } from "@auth0/universal-components-react";
> > import { Auth0Provider } from "@auth0/auth0-react";
> > import { Auth0ComponentProvider } from "@auth0/universal-components-react/spa";
> > import { analytics } from "./lib/analytics";
> >
> > function SecurityPage() {
> >   return (
> >     <div className="max-w-3xl mx-auto p-6">
> >       <UserPasskeyManagement
> >         addAction={{
> >           onAfter: () => {
> >             analytics.track("Passkey Enrolled");
> >           },
> >         }}
> >         revokeAction={{
> >           onBefore: (passkey) =>
> >             window.confirm(`Remove passkey "${passkey.name}"?`),
> >           onAfter: (passkey) => {
> >             analytics.track("Passkey Revoked", { passkeyId: passkey.id });
> >           },
> >         }}
> >         customMessages={{
> >           header: {
> >             title: "Passkeys",
> >             description: "Sign in faster and more securely without a password.",
> >           },
> >         }}
> >         styling={{
> >           variables: {
> >             light: { "--color-primary": "#4f46e5" },
> >             dark: { "--color-primary": "#818cf8" },
> >           },
> >         }}
> >       />
> >     </div>
> >   );
> > }
> >
> > export default function App() {
> >   const domain = "YOUR_TENANT_DOMAIN.auth0.com";
> >   const clientId = "YOUR_CLIENT_ID";
> >
> >   return (
> >     <Auth0Provider
> >       domain={domain}
> >       clientId={clientId}
> >       authorizationParams={{ redirect_uri: window.location.origin }}
> >       interactiveErrorHandler="popup"
> >     >
> >       <Auth0ComponentProvider>
> >         <SecurityPage />
> >       </Auth0ComponentProvider>
> >     </Auth0Provider>
> >   );
> > }
> > ```

> [tab] Next.js（RWA）
>
> ## コンポーネントをインストールする
>
> ```bash pnpm wrap lines theme={null}
> pnpm add @auth0/universal-components-react react-hook-form @tanstack/react-query
> ```
>
> ```bash npm wrap lines theme={null}
> npm install @auth0/universal-components-react react-hook-form @tanstack/react-query
> ```
>
> `react-hook-form` と `@tanstack/react-query` はピア依存関係です。このコマンドにより、共有ユーティリティおよび Auth0 連携に必要な `@auth0/universal-components-core` もインストールされます。
>
> ## はじめに
>
> ```tsx app/security/passkeys/page.tsx wrap lines theme={null}
> "use client";
>
> import { UserPasskeyManagement } from "@auth0/universal-components-react";
>
> export default function PasskeysPage() {
>   return <UserPasskeyManagement />;
> }
> ```
>
> > [accordion] 連携の完全な例
> >
> > ```tsx app/security/passkeys/page.tsx wrap lines theme={null}
> > "use client";
> >
> > import { UserPasskeyManagement } from "@auth0/universal-components-react";
> > import { analytics } from "@/lib/analytics";
> >
> > export default function PasskeysPage() {
> >   return (
> >     <div className="max-w-3xl mx-auto p-6">
> >       <UserPasskeyManagement
> >         addAction={{
> >           onAfter: () => {
> >             analytics.track("Passkey Enrolled");
> >           },
> >         }}
> >         revokeAction={{
> >           onAfter: (passkey) => {
> >             analytics.track("Passkey Revoked", { passkeyId: passkey.id });
> >           },
> >         }}
> >         customMessages={{
> >           header: {
> >             title: "Passkeys",
> >             description: "Sign in faster and more securely without a password.",
> >           },
> >         }}
> >         styling={{
> >           variables: {
> >             light: { "--color-primary": "#4f46e5" },
> >             dark: { "--color-primary": "#818cf8" },
> >           },
> >         }}
> >       />
> >     </div>
> >   );
> > }
> > ```

> [tab] shadcn
>
> ## コンポーネントをインストールする
>
> ```bash wrap lines theme={null}
> npx shadcn@latest add auth0/auth0-ui-components/react/my-account/user-passkey-management
> ```
>
> インストールコマンドを実行すると、コンポーネントのソースがすべての UI 依存関係とともに `src/components/auth0/my-account/` に追加されます。また、共有ユーティリティと Auth0 連携に必要な `@auth0/universal-components-core` 依存関係も追加されます。
>
> **レガシー Vercel レジストリーの提供終了**：Vercel ホスト型のレジストリー
> (`https://auth0-universal-components.vercel.app/r/...`) は
> **2026 年 9 月 17 日**に提供を終了しました。上記の GitHub Registry のパスを使用してください。
>
> ## はじめに
>
> ```tsx wrap lines theme={null}
> import { UserPasskeyManagement } from "@/components/auth0/my-account/user-passkey-management";
>
> export function SecurityPage() {
>   return <UserPasskeyManagement />;
> }
> ```
>
> > [accordion] 連携の完全な例
> >
> > ```tsx wrap lines theme={null}
> > import React from "react";
> > import { UserPasskeyManagement } from "@/components/auth0/my-account/user-passkey-management";
> > import { Auth0Provider } from "@auth0/auth0-react";
> > import { Auth0ComponentProvider } from "@auth0/universal-components-react/spa";
> > import { analytics } from "./lib/analytics";
> >
> > function SecurityPage() {
> >   return (
> >     <div className="max-w-3xl mx-auto p-6">
> >       <UserPasskeyManagement
> >         addAction={{
> >           onAfter: () => {
> >             analytics.track("Passkey Enrolled");
> >           },
> >         }}
> >         revokeAction={{
> >           onBefore: (passkey) =>
> >             window.confirm(`Remove passkey "${passkey.name}"?`),
> >           onAfter: (passkey) => {
> >             analytics.track("Passkey Revoked", { passkeyId: passkey.id });
> >           },
> >         }}
> >         customMessages={{
> >           header: {
> >             title: "Passkeys",
> >             description: "Sign in faster and more securely without a password.",
> >           },
> >         }}
> >         styling={{
> >           variables: {
> >             light: { "--color-primary": "#4f46e5" },
> >             dark: { "--color-primary": "#818cf8" },
> >           },
> >         }}
> >       />
> >     </div>
> >   );
> > }
> >
> > export default function App() {
> >   const domain = "YOUR_TENANT_DOMAIN.auth0.com";
> >   const clientId = "YOUR_CLIENT_ID";
> >
> >   return (
> >     <Auth0Provider
> >       domain={domain}
> >       clientId={clientId}
> >       authorizationParams={{ redirect_uri: window.location.origin }}
> >       interactiveErrorHandler="popup"
> >     >
> >       <Auth0ComponentProvider>
> >         <SecurityPage />
> >       </Auth0ComponentProvider>
> >     </Auth0Provider>
> >   );
> > }
> > ```

## プロップス

### 表示プロップス

表示プロップスは、コンポーネントの動作に影響を与えずに表示方法を制御します。

<table>
  <thead>
    <tr>
      <th>プロップス</th>
      <th>型</th>
      <th>デフォルト</th>
      <th>説明</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`hideHeader`</td>
      <td>`boolean`</td>
      <td>`false`</td>
      <td>ページのヘッダー (タイトルと説明) を非表示にします。パスキー一覧を含むセクションカードは常に表示されます。</td>
    </tr>
  </tbody>
</table>

### Action プロップス

Action プロップスを使用すると、コンポーネントのライフサイクルイベントにフックして、操作をトリガーまたはキャンセルできます。

<table>
  <thead>
    <tr>
      <th>プロップ</th>
      <th>型</th>
      <th>説明</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`addAction`</td>
      <td>`ComponentAction<void>`</td>
      <td>パスキー追加フロー用のライフサイクルフックです。追加ボタンを非表示にするには、`disabled: true`を設定します。</td>
    </tr>

    <tr>
      <td>`revokeAction`</td>
      <td>`ComponentAction<Passkey>`</td>
      <td>パスキー取り消しフロー用のライフサイクルフックです。取り消しオプションを非表示にするには、`disabled: true`を設定します。</td>
    </tr>

    <tr>
      <td>`onFetch`</td>
      <td>`() => void`</td>
      <td>パスキーのリストが正常に読み込まれた後にトリガーされます。</td>
    </tr>
  </tbody>
</table>

**addAction**

パスキー追加フローを制御します。`onBefore`はブラウザーにWebAuthnプロンプトが表示される前にトリガーされます。キャンセルするには`false`を返します (たとえば、パスキー数の上限を設ける場合) 。`onAfter`は新しいパスキーが保存された後にトリガーされます。

* `disabled`は「パスキーを追加」ボタンを非表示にします。
* `onBefore()`はWebAuthn登録セレモニーの前に実行されます。キャンセルするには`false`を返します。
* `onAfter()`はパスキーが正常に登録された後に実行されます。セッションの状態を更新したり、分析データを送信したりする際に使用します。

```tsx wrap lines theme={null}
<UserPasskeyManagement
  addAction={{
    onBefore: () => {
      if (passkeys.length >= 5) {
        toast.error("You can register a maximum of 5 passkeys.");
        return false;
      }
      return true;
    },
    onAfter: () => {
      analytics.track("Passkey Enrolled");
    },
  }}
/>
```

**revokeAction**

パスキーの取り消しフローを制御します。`onBefore` は組み込みの確認モーダルが表示される前に実行されるため、ユーザーにモーダルが表示される前にフローをキャンセルできます。`onAfter` は、パスキーがアカウントから削除された後にトリガーされます。

* `disabled` は、パスキーアクションメニューから取り消しオプションを非表示にします。
* `onBefore(passkey)` は、取り消し API 呼び出しの前に実行されます。`Passkey` オブジェクトを受け取ります。キャンセルするには `false` を返します。
* `onAfter(passkey)` は、パスキーが正常に取り消された後に実行されます。取り消された `Passkey` オブジェクトを受け取ります。

```tsx wrap lines theme={null}
<UserPasskeyManagement
  revokeAction={{
    onAfter: (passkey) => {
      auditLog.record({ action: "passkey_revoked", passkeyId: passkey.id });
    },
  }}
/>
```

**onFetch**

マウント時にパスキーのリストが正常に読み込まれた後にトリガーされます。ユーザーに登録済みのパスキーがあるかどうかに応じて、関連するUIを表示または非表示にするために使用します。

```tsx wrap lines theme={null}
<UserPasskeyManagement
  onFetch={() => {
    setPasskeysLoaded(true);
  }}
/>
```

リストを読み取り専用でレンダリングするには、両方のActionで `disabled: true` を設定します。

```tsx wrap lines theme={null}
<UserPasskeyManagement
  addAction={{ disabled: true }}
  revokeAction={{ disabled: true }}
/>
```

### プロップスをカスタマイズする

カスタマイズ用プロップスを使用すると、ソースコードを変更せずに文言やスタイリングを調整できます。

<table>
  <thead>
    <tr>
      <th>プロップス</th>
      <th>型</th>
      <th>説明</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`customMessages`</td>
      <td>`Partial<UserPasskeyManagementMessages>`</td>
      <td>デフォルトのUIテキストと翻訳を上書きします。</td>
    </tr>

    <tr>
      <td>`styling`</td>
      <td>`ComponentStyling<UserPasskeyManagementClasses>`</td>
      <td>CSS変数とクラスの上書き。</td>
    </tr>
  </tbody>
</table>

**customMessages**

すべてのテキストと翻訳をカスタマイズできます。すべてのフィールドは任意です。

> [accordion] 利用可能なメッセージ
>
> * **header**—`title`、`description` (ページレベルのヘッダー。`hideHeader` が `true` の場合は非表示)
> * **トップレベルのカード**—`section_title`、`enabled` (パスキーが登録されている場合に表示されるバッジ) 、`no_passkeys` (パスキーがない場合に表示するメッセージ) 、`add_passkey` (追加ボタンのラベル)
> * **リスト項目**—`created_at` (プレースホルダーとして `${date}` を使用) 、`last_used` (プレースホルダーとして `${date}` を使用)
> * **Actions**—`actions.revoke` (パスキーごとのアクションメニュー内のラベル)
> * **成功トースト**—`success.add`、`success.revoke`
> * **取り消し確認モーダル**—`modals.revoke.title`、`modals.revoke.consent` (パスキー名を太字にするには `<bold>${name}</bold>` を使用) 、`modals.revoke.cancel`、`modals.revoke.confirm`

```tsx wrap lines theme={null}
<UserPasskeyManagement
  customMessages={{
    header: {
      title: "Passkeys",
      description: "Sign in faster and more securely without a password.",
    },
    section_title: "Your passkeys",
    no_passkeys: "No passkeys registered yet.",
    add_passkey: "Add a passkey",
    created_at: "Added ${date}",
    last_used: "Last used ${date}",
    success: {
      add: "Passkey registered successfully.",
      revoke: "Passkey removed.",
    },
    modals: {
      revoke: {
        title: "Remove passkey?",
        consent: "This will permanently remove <bold>${name}</bold>.",
        cancel: "Cancel",
        confirm: "Remove",
      },
    },
  }}
/>
```

**スタイルをカスタマイズ**

CSS変数とクラスのオーバーライドを使用して外観をカスタマイズできます。ライト/ダークテーマに対応しています。

> [accordion] 利用可能なスタイリングオプション
>
> **変数**—CSSカスタムプロパティ
>
> * `common` 両方のテーマに適用
> * `light` ライトモードのみ
> * `dark` ダークモードのみ
>
> **クラスのオーバーライド**
>
> * `UserPasskeyManagement-root` パスキーリストを囲む外側のカードコンテナ
> * `UserPasskeyManagement-item` 各パスキー行のカード
> * `PasskeyActionModal-modalContent` 取り消し確認モーダルのコンテンツ領域

```tsx wrap lines theme={null}
<UserPasskeyManagement
  styling={{
    variables: {
      light: { "--color-primary": "#4f46e5" },
      dark: { "--color-primary": "#818cf8" },
    },
    classes: {
      "UserPasskeyManagement-root": "rounded-2xl shadow-md",
      "UserPasskeyManagement-item": "rounded-xl border border-gray-200",
      "PasskeyActionModal-modalContent": "max-w-sm",
    },
  }}
/>
```

## TypeScript 型定義

```typescript wrap lines theme={null}
interface Passkey {
  id: string;
  name?: string;
  createdAt?: string;
  lastUsedAt?: string;
  deviceInfo?: string;
}

interface UserPasskeyManagementClasses {
  "UserPasskeyManagement-root"?: string;
  "UserPasskeyManagement-item"?: string;
  "PasskeyActionModal-modalContent"?: string;
}

// ComponentActionは、実行前後のフックと無効化フラグを提供します。
// 両方のフックは同じデータ型Tを受け取ります。
interface ComponentAction<Item, Context = void> {
  disabled?: boolean;
  onBefore?: (item: Item, context?: Context) => boolean;
  onAfter?: (item: Item, context?: Context) => void | boolean | Promise<boolean>;
}

interface UserPasskeyManagementProps {
  hideHeader?: boolean;
  customMessages?: Partial<UserPasskeyManagementMessages>;
  styling?: ComponentStyling<UserPasskeyManagementClasses>;
  addAction?: ComponentAction<void>;
  revokeAction?: ComponentAction<Passkey>;
  onFetch?: () => void;
}
```

## 高度なカスタマイズ

上記のコンポーネント設定に加え、パスキー管理用のカスタムインターフェースを構築する必要がある場合は、`useUserPasskey` フックを使用します。

```tsx wrap lines theme={null}
import { useUserPasskey } from "@auth0/universal-components-react";

export function CustomPasskeyManagement() {
  const {
    passkeys,
    isLoading,
    isEnrolling,
    isRevoking,
    disableAdd,
    disableRevoke,
    currentPasskey,
    isRevokeModalOpen,
    setIsRevokeModalOpen,
    handleAddPasskey,
    handleRevokePasskey,
    handleConfirmRevoke,
  } = useUserPasskey({});

  if (isLoading) return <p>Loading passkeys…</p>;

  return (
    <>
      <button disabled={disableAdd || isEnrolling} onClick={handleAddPasskey}>
        Add passkey
      </button>

      <ul>
        {passkeys.map((passkey) => (
          <li key={passkey.id}>
            {passkey.name ?? "Unnamed passkey"}
            <button
              disabled={disableRevoke || isRevoking}
              onClick={() => handleRevokePasskey(passkey)}
            >
              Remove
            </button>
          </li>
        ))}
      </ul>

      {isRevokeModalOpen && currentPasskey && (
        <div role="dialog" aria-modal="true">
          <p>Remove {currentPasskey.name ?? "passkey"}?</p>
          <button disabled={isRevoking} onClick={handleConfirmRevoke}>
            Confirm removal
          </button>
          <button onClick={() => setIsRevokeModalOpen(false)}>Cancel</button>
        </div>
      )}
    </>
  );
}
```

フックは `customMessages`、`addAction`、`revokeAction`、`onFetch` を受け取ります。パスキーデータ、読み込み状態とアクションの状態、現在の取り消し対象、パスキーの登録および取り消し用ハンドラーを返します。

組み込みのインターフェースを使用する場合は、`UserPasskeyManagement` を使用してください。フックを使用する場合は、対応する取り消し確認 UI と、それを閉じる動作を実装してください。

## 詳しく見る

> [card] [ユーザーのMFA管理](/docs/docs/ja-jp/get-started/universal-components/web/components/user-mfa-management)
>
> パスキーと併せて、MFA認証要素 (TOTP、SMS、メールOTP、プッシュ、リカバリーコード) を管理します。

> [card] [セルフサービスのアカウントセキュリティインターフェースを構築する](/docs/docs/ja-jp/get-started/universal-components/web/components/my-account-overview)
>
> すべてのMy Accountコンポーネントの概要、前提条件、フレームワークの設定方法を紹介します。
