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

# LoginPasswordlessSmsOtp

> Universal Login の `login-passwordless-sms-otp` 画面をカスタマイズするために利用できる、すべての Hooks とメソッドについて説明します。

`login-passwordless-sms-otp` 画面では、SMS によるパスワードレス SMS 認証を完了するために、ユーザーに電話番号に送信されたワンタイムパスワードの入力を求めます。

![Login パスワードレス SMS OTP](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/cdy7uua7fh8z/7CNCkaU1uPRbEUsAyqlj8u/8461823cf224471d19656e4dd9027a87/Screenshot_2025-04-24_at_11.31.00.png)

## インポート

各画面には、それぞれ固有の Hooks とメソッドがあります。SDK は、各画面で**部分インポート**と**ルートインポート**をサポートしています。

* 部分インポートを使うと、特定のユースケースに必要なコードだけを取り込めます。
* ルートインポートを使うと、単一のバンドルからすべての画面を読み込めます。これは、想定されるすべての画面に対応する単一のビルドを使いたい場合に便利です。

```jsx Import Example theme={null}
// ルートインポート
import { useLoginPasswordlessSmsOtp } from '@auth0/auth0-acul-react';

// 部分インポート
import {
  useLoginPasswordlessSmsOtp,
  // コンテキストHooks
  useUser,
  useTenant,
  useBranding,
  useClient,
  useOrganization,
  usePrompt,
  useScreen,
  useTransaction,
  useUntrustedData,
  useExperiment,
  // 共通Hooks
  useCurrentScreen,
  useAuth0Themes,
  useErrors,
  // ユーティリティHooks
  useChangeLanguage,
  useResend,
  // メソッド
  submitOTP,
  resendOTP,
  switchConnection,
} from '@auth0/auth0-acul-react/login-passwordless-sms-otp';

function SmsOtpForm() {
  const { submitOTP } = useLoginPasswordlessSmsOtp();
  return (
    <button onClick={() => submitOTP({ code: '123456' })}>
      Verify Code
    </button>
  );
}
```

## Context Hooks

`login-passwordless-sms-otp` 画面で Auth0 のコンテキストデータへの読み取り専用アクセスを提供する、画面に対してスコープが設定された Hooks です。`@auth0/auth0-acul-react/login-passwordless-sms-otp` からインポートします。

**useBranding** `() => [BrandingMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/BrandingMembers)`

この Hooks は、`login-passwordless-sms-otp` 画面に表示されるロゴ、色、テーマ設定などの ブランディング 設定を提供します。

```jsx Example theme={null}
import { useBranding } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function CustomTheme() {
  const branding = useBranding();
}
```

**useClient** `() => [ClientMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ClientMembers)`

この Hooks は、`login-passwordless-sms-otp` 画面の `id`、`name`、`logoUrl` など、クライアントに関連する設定を提供します。

```jsx Example theme={null}
import { useClient } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function AppInfo() {
  const client = useClient();
}
```

**useExperiment** `() => [ExperimentMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ExperimentMembers)`

この Hooks は、`login-passwordless-sms-otp` 画面で現在有効な [Experiment Center](/docs/docs/ja-jp/customize/experiment-center) の実験を提供します。有効な実験がない場合 (または画面が `context_configuration` でオプトインしていない場合) は `null` を返します。

```jsx Example theme={null}
import { useExperiment } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function ExperimentBranch() {
  const experiment = useExperiment();
  if (!experiment) return null;
  return experiment.isControl ? <ControlUI /> : <TreatmentUI />;
}
```

**useOrganization** `() => [OrganizationMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/OrganizationMembers)`

この Hooks は、ログインが organization にスコープ設定されている場合に、ユーザーの 組織 に関する情報を提供します。組織コンテキストが存在しない場合は `null` を返します。

```jsx Example theme={null}
import { useOrganization } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function OrgSelector() {
  const organization = useOrganization();
  if (!organization) {
    return <p>No organization context</p>;
  }
}
```

**usePrompt** `() => [PromptMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/PromptMembers)`

この Hooks には、認証フロー内の現在のプロンプトに関するデータが含まれます。

```jsx Example theme={null}
import { usePrompt } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function FlowInfo() {
  const prompt = usePrompt();
}
```

**useScreen** `() => [ScreenMembersOnLoginPasswordlessSmsOtp](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ScreenMembersOnLoginPasswordlessSmsOtp)`

この Hooks には、`login-passwordless-sms-otp` 画面に固有の詳細情報 (設定やコンテキストを含む) が含まれます。

```jsx Example theme={null}
import { useScreen } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function ScreenDebug() {
  const screen = useScreen();
}
```

**useTenant** `() => [TenantMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/TenantMembers)`

この Hooks には、`id` や関連するメタデータなど、テナントに関するデータが含まれます。

```jsx Example theme={null}
import { useTenant } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function TenantInfo() {
  const tenant = useTenant();
}
```

**useTransaction** `() => [TransactionMembersOnLoginPasswordlessSmsOtp](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/TransactionMembersOnLoginPasswordlessSmsOtp)`

この Hooks は、`login-passwordless-sms-otp` 画面の transaction 固有のデータ (有効な 接続 や現在のフロー state など) を提供します。

```jsx Example theme={null}
import { useTransaction } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function TransactionInfo() {
  const transaction = useTransaction();
}
```

**useUntrustedData** `() => [UntrustedDataMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/UntrustedDataMembers)`

この Hooks は、URLパラメーター から事前入力された phone 番号など、画面に渡される信頼されていないデータを扱います。

```jsx Example theme={null}
import { useUntrustedData } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function PrefilledForm() {
  const untrustedData = useUntrustedData();
}
```

**useUser** `() => [UserMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/UserMembers)`

この Hooks は、`username`、`email`、利用可能な認証方法など、アクティブなユーザーの詳細情報を提供します。

```jsx Example theme={null}
import { useUser } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';
function UserProfile() {
  const user = useUser();
}
```

**useLoginPasswordlessSmsOtp** `[LoginPasswordlessSmsOtpMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/LoginPasswordlessSmsOtpMembers)`

この Hooks は、`login-passwordless-sms-otp` 画面で利用できるすべてのメソッドとコンテキストを返します。

## メソッド

**resendOTP** `Promise\<void\>`

ワンタイムパスワード (OTP) をユーザーの電話番号に再送します。

このメソッドは Auth0 にフォームを送信し、Auth0 はこのスクリーンを再度レンダリングします。captcha が必要な場合は、代わりに `login-id` スクリーン (ユーザーがサインアップから開始した場合は `signup-id` スクリーン) にユーザーを戻します。いずれの場合もブラウザーが新しいページを読み込むため、React の状態、エフェクト、タイマーは失われます。

`resendOTP()` を呼び出す際は、次の点に注意してください。

* `await resendOTP()` の後に実行されるコードで設定した状態 (「コード送信済み」メッセージやカウントダウンなど) は、保持されることを前提にできません。
* レート制限などの理由で Auth0 が SMS を送信できなかった場合、Auth0 はエラーを表示せずにこのスクリーンを再度レンダリングします。ページの再読み込み後に `useErrors()` に表示されるのは、Extensibility のエラー (アクションからのエラーなど) と予期しない障害のみです。返される Promise が reject されることはありません。
* 返される Promise は、フォームが送信された時点 (新しいページが読み込まれる前) で resolve します。そのため、Auth0 が新しいコードを送信したことの確認にはなりません。

再送の間にクールダウンを設けるには、`useResend()` を使用します。`useResend()` Hooks はカウントダウンを `localStorage` に保存するため、ページを再読み込みしてもカウントダウンは維持されます。

```jsx Example theme={null}
import { useLoginPasswordlessSmsOtp } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';

function ResendButton() {
  const { resendOTP } = useLoginPasswordlessSmsOtp();
  return (
    <button onClick={() => resendOTP()}>
      コードを再送信
    </button>
  );
}
```

**submitOTP** `Promise\<void\>`

このメソッドは、ワンタイムパスワードを送信してパスワードレス SMS 認証を完了します。

```jsx Example theme={null}
import { useLoginPasswordlessSmsOtp } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';

function SmsOtpForm() {
  const { submitOTP } = useLoginPasswordlessSmsOtp();
  return (
    <button onClick={() => submitOTP({ code: '123456' })}>
      コードを検証
    </button>
  );
}
```

**メソッドのパラメーター**

**パラメータ**

**options**

[SubmitOTPOptions](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/SubmitOTPOptions).

**code** `string` *required*

ユーザーの電話番号に送信されたワンタイムパスワード。

**username?** `string`

フローで必要な場合に指定する、ユーザーの電話番号または識別子。

**captcha?** `string`

テナントでボット検出が有効な場合に必要な captcha 値。

**switchConnection** `Promise\<void\>`

このメソッドは、フローを最初からやり直すことなく、別の認証用接続に切り替えます。

```jsx Example theme={null}
import { useLoginPasswordlessSmsOtp } from '@auth0/auth0-acul-react/login-passwordless-sms-otp';

function ConnectionSwitcher() {
  const { switchConnection } = useLoginPasswordlessSmsOtp();
  return (
    <button onClick={() => switchConnection({ connection: 'enterprise-saml' })}>
      SSO を使用
    </button>
  );
}
```

**メソッドのパラメーター**

**パラメータ**

**options**

[SwitchConnectionOptionsSmsOtp](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/SwitchConnectionOptionsSmsOtp).

**connection** `string` *required*

切り替え先の接続名。パスワードレスの場合は 'email' または 'sms' を、パスワードベース認証の場合は DB 接続名を使用します。

## 共通/ユーティリティ Hooks

**[useAuth0Themes](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useAuth0Themes)** `Hooks`

このHooksは、ブランディングコンテキストから、フラット化された設定を含む現在のテーマオプションを取得します。

**[useChangeLanguage](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useChangeLanguage)** `Hooks`

このHooksは、現在のACULスクリーンの表示言語を変更する関数を返します。

**[useCurrentScreen](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useCurrentScreen)** `Hooks`

このHooksは、現在のスクリーンのコンテキストと状態を取得します。

**[useErrors](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useErrors)** `Hooks`

このHooksは、スクリーン上のサーバー、クライアント、開発者のエラーを読み取り、管理します。

**[useResend](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useResend)** `Hooks`

このスクリーンの再送クールダウンを管理します。このHooksは、残り秒数、再送が無効かどうか、そして再送を実行してクールダウンを開始する`startResend()`関数を返します。カウントダウンは、再送に伴うページの再読み込み後も維持されます。
