with one click
kb-frontend-amplify-ui
Amplify UI Reactのナレッジ。Authenticator/日本語化/認証フロー/配色カスタマイズ等
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Amplify UI Reactのナレッジ。Authenticator/日本語化/認証フロー/配色カスタマイズ等
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Tavily APIキーの残りクレジットを確認(.envから取得)。※アプリの利用統計は /check-app-stats を使用
ローカルのマージ済みGitブランチを整理・削除する
リポジトリ内の未プッシュの変更をすべて確認し、適切なコミットに分割してコミット&プッシュする
1Password CLI(op コマンド)のナレッジ。.env.op テンプレートから .env 生成、op-sync、Touch ID最小化、Vault構成、アカウント切替等
AgentCore CDK・デプロイ・ランタイム統合のナレッジ。Runtime作成、JWT認証、SSE、Dockerfile、コンテナ管理、Browser Tool等
AgentCore Identity(アウトバウンド認証)のナレッジ。3LO/M2M/デコレータ分離/callback等
| name | kb-frontend-amplify-ui |
| description | Amplify UI Reactのナレッジ。Authenticator/日本語化/認証フロー/配色カスタマイズ等 |
| user-invocable | true |
| model | sonnet |
Amplify UI React を使った認証UI・カスタマイズのパターンを記録する。
import { Authenticator } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';
function App() {
return (
<Authenticator>
{({ signOut, user }) => (
<main>
<h1>Hello {user?.username}</h1>
<button onClick={signOut}>Sign out</button>
</main>
)}
</Authenticator>
);
}
// main.tsx
import { I18n } from 'aws-amplify/utils';
import { translations } from '@aws-amplify/ui-react';
I18n.putVocabularies(translations);
I18n.setLanguage('ja');
Cognito認証画面にアプリ名やプライバシーポリシーを表示する:
const authComponents = {
Header() {
return (
<div className="text-center py-4">
<h1 className="text-2xl font-bold text-gray-800">アプリ名</h1>
<p className="text-sm text-gray-500 mt-1">
「Create Account」で誰でも利用できます!
</p>
</div>
);
},
Footer() {
return (
<div className="text-center py-3 px-4">
<p className="text-xs text-gray-400 leading-relaxed">
登録されたメールアドレスは認証目的でのみ使用します。
</p>
</div>
);
},
};
<Authenticator components={authComponents}>
{({ signOut }) => <MainApp signOut={signOut} />}
</Authenticator>
用途例:
Authenticatorのデフォルト認証フローを変更する場合、services propで handleSignIn をオーバーライドする。
import { signIn } from 'aws-amplify/auth';
<Authenticator
components={authComponents}
services={{
handleSignIn: (input) => signIn({
...input,
options: { authFlowType: 'USER_PASSWORD_AUTH' }
}),
}}
>
主なユースケース: Cognito User Migration Trigger。Migration TriggerはパスワードがLambdaに平文で渡される USER_PASSWORD_AUTH フローでのみ発火する。
| 認証フロー | パスワード | Migration Trigger |
|---|---|---|
USER_SRP_AUTH(デフォルト) | 暗号化して送信 | 発火しない |
USER_PASSWORD_AUTH | 平文で送信 | 発火する |
createTheme/ThemeProviderではグラデーションが使えないため、CSSで直接スタイリングするのが確実。
/* src/index.css */
/* プライマリボタン(グラデーション対応) */
[data-amplify-authenticator] .amplify-button--primary {
background: linear-gradient(to right, #1a3a6e, #5ba4d9);
border: none;
}
[data-amplify-authenticator] .amplify-button--primary:hover {
background: linear-gradient(to right, #142d54, #4a93c8);
}
/* リンク(パスワードを忘れた等) */
[data-amplify-authenticator] .amplify-button--link {
color: #1a3a6e;
}
/* タブ */
[data-amplify-authenticator] .amplify-tabs__item--active {
color: #1a3a6e;
border-color: #5ba4d9;
}
/* 入力フォーカス */
[data-amplify-authenticator] input:focus {
border-color: #5ba4d9;
box-shadow: 0 0 0 2px rgba(91, 164, 217, 0.2);
}
ポイント:
[data-amplify-authenticator]セレクタで認証画面のみに適用createThemeはグラデーション非対応 → CSS直接指定が確実