Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.
Gen1 DocsLegacy

Page updated Mar 26, 2026

サインアップ

Amplifyは、Amplify Authなどのバックエンドリソースと対話できるクライアントライブラリを提供します。

Amplify Authをフロントエンドアプリケーションで最も簡単に始める方法は、Authenticatorコンポーネントを使用することです。このコンポーネントはカスタマイズ可能なUIと完全な認証フローを提供します。

まず、signUp() APIを使用してバックエンドに新しいユーザーを作成できます:

import { signUp } from "aws-amplify/auth"
const { isSignUpComplete, userId, nextStep } = await signUp({
username: "hello@mycompany.com",
password: "hunter2",
options: {
userAttributes: {
email: "hello@mycompany.com",
phone_number: "+15555555555" // E.164 number convention
},
}
});

signUp APIレスポンスには nextStep プロパティが含まれており、これを使用して追加のアクションが必要かどうかを判定できます。以下のネクストステップが返される可能性があります:

ネクストステップ説明
CONFIRM_SIGN_UPサインアップをユーザーからコードを収集して confirmSignUp を呼び出すことで確認する必要があります。
DONEサインアッププロセスが完全に完了しました。
COMPLETE_AUTO_SIGN_INサインアッププロセスを autoSignIn APIを呼び出して完了する必要があります。

サインアップの確認

デフォルトでは、サインアップしたすべてのユーザーは、メールアドレスまたは電話番号に送信された確認コードで確認するまで、未確認のステータスのままです。以下は、loginWith オプションとして phone または email が使用される場合に使用されるデフォルトの検証方法です。

ログインオプションユーザーアカウント検証チャネル
phone電話番号
emailメール
emailphoneメール

ユーザーから確認コードを受け取った後、サインアップを確認できます:

import { confirmSignUp } from 'aws-amplify/auth';
const { isSignUpComplete, nextStep } = await confirmSignUp({
username: "hello@mycompany.com",
confirmationCode: "123456"
});

注: ユーザーがサインインする方法として email または phone を指定する場合、これらはユーザー名の代わりに使用される属性です。詳細については、コンセプトページをご覧ください

実践的な例

src/App.tsx
import type { FormEvent } from "react"
import { Amplify } from "aws-amplify"
import { signUp } from "aws-amplify/auth"
import outputs from "../amplify_outputs.json"
Amplify.configure(outputs)
interface SignUpFormElements extends HTMLFormControlsCollection {
email: HTMLInputElement
password: HTMLInputElement
}
interface SignUpForm extends HTMLFormElement {
readonly elements: SignUpFormElements
}
export default function App() {
async function handleSubmit(event: FormEvent<SignUpForm>) {
event.preventDefault()
const form = event.currentTarget
// ... validate inputs
await signUp({
username: form.elements.email.value,
password: form.elements.password.value,
})
}
return (
<form onSubmit={handleSubmit}>
<label htmlFor="email">Email:</label>
<input type="text" id="email" name="email" />
<label htmlFor="password">Password:</label>
<input type="password" id="password" name="password" />
<input type="submit" />
</form>
)
}

パスワードレス方式でのサインアップ

アプリケーションのユーザーはパスワードレス方式を使用してサインアップすることもできます。詳細については、パスワードレスのコンセプトページをご覧ください。

SMS OTP

// 電話番号を使用してサインアップします
const { nextStep: signUpNextStep } = await signUp({
username: 'hello',
options: {
userAttributes: {
phone_number: '+15555551234',
},
},
});
if (signUpNextStep.signUpStep === 'DONE') {
console.log(`SignUp Complete`);
}
if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {
console.log(
`Code Delivery Medium: ${signUpNextStep.codeDeliveryDetails.deliveryMedium}`,
);
console.log(
`Code Delivery Destination: ${signUpNextStep.codeDeliveryDetails.destination}`,
);
}
// 受け取ったOTPでサインアップを確認します
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'hello',
confirmationCode: '123456',
});
if (confirmSignUpNextStep.signUpStep === 'DONE') {
console.log(`SignUp Complete`);
}

メールOTP

// メールアドレスを使用してサインアップします
const { nextStep: signUpNextStep } = await signUp({
username: 'hello',
options: {
userAttributes: {
email: 'hello@example.com',
},
},
});
if (signUpNextStep.signUpStep === 'DONE') {
console.log(`SignUp Complete`);
}
if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {
console.log(
`Code Delivery Medium: ${signUpNextStep.codeDeliveryDetails.deliveryMedium}`,
);
console.log(
`Code Delivery Destination: ${signUpNextStep.codeDeliveryDetails.destination}`,
);
}
// 受け取ったOTPでサインアップを確認します
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'hello',
confirmationCode: '123456',
});
if (confirmSignUpNextStep.signUpStep === 'DONE') {
console.log(`SignUp Complete`);
}

自動サインイン

// 認証フロータイプとして `USER_AUTH` を指定して `signUp` APIを呼び出します
const { nextStep: signUpNextStep } = await signUp({
username: 'hello',
options: {
userAttributes: {
email: 'hello@example.com',
phone_number: '+15555551234',
},
autoSignIn: {
authFlowType: 'USER_AUTH',
},
},
});
if (signUpNextStep.signUpStep === 'CONFIRM_SIGN_UP') {
console.log(
`Code Delivery Medium: ${signUpNextStep.codeDeliveryDetails.deliveryMedium}`,
);
console.log(
`Code Delivery Destination: ${signUpNextStep.codeDeliveryDetails.destination}`,
);
}
// 受け取ったOTPで `confirmSignUp` APIを呼び出します
const { nextStep: confirmSignUpNextStep } = await confirmSignUp({
username: 'hello',
confirmationCode: '123456',
});
if (confirmSignUpNextStep.signUpStep === 'COMPLETE_AUTO_SIGN_IN') {
// フローを完了するために `autoSignIn` APIを呼び出します
const { nextStep } = await autoSignIn();
if (nextStep.signInStep === 'DONE') {
console.log('Successfully signed in.');
}
}