Need to configure your backend?See Build a Backend →
Authenticator の使用
フロントエンドアプリケーションで Amplify Auth を始める最も簡単な方法は、カスタマイズ可能な UI と完全な認証フローを提供する Authenticator コンポーネント です。
import Amplifyimport Authenticatorimport AWSCognitoAuthPluginimport SwiftUI
@mainstruct MyApp: App { init() { do { try Amplify.add(plugin: AWSCognitoAuthPlugin()) try Amplify.configure(with: .amplifyOutputs) } catch { print("Unable to configure Amplify \(error)") } }
var body: some Scene { WindowGroup { Authenticator { state in VStack { Text("Hello, \(state.user.username)") Button("Sign out") { Task { await state.signOut() } } } } } }}Authenticator コンポーネントは、バックエンドから生成された出力に基づいて自動的に設定されます。Authenticator の詳細とその外観をカスタマイズする方法について詳しくは、Amplify UI ドキュメント を参照してください。