amplifyでCognitoを作成
下記の内容を参考にCognitoを作成しましょう。
その際、カスタム属性の作成はできません。できるのは標準属性のみが作成できます。
cognitoにカスタム属性を追加
awsコンソールを表示してcognitoのユーザープールに移動します。上記で作成したユーザープールを選択して、サインアップエクスペリエンスタブを選択してカスタム属性を追加してください。
amplifyのライブラリでカスタム属性を取得
import { useAuthenticator } from '@aws-amplify/ui-react'
const {user} = useAuthenticator()
上記を使って、attributes(属性)を取得します。その際、自分は取得できませんでした...
しかし、下記のようにamplify/backend/auth/{ユーザープールのID}/cli-inputs.json
に
"userpoolClientReadAttributes": [
"email",
"name",
"custom:test"
]
を設定したら読めるようになりました。