Delete user account
These docs cover Amplify Gen 1. For new web apps, we recommend the latest AWS Amplify, with a simplified CLI and native integrations for databases, storage, and AI models. Get started with the latest AWS Amplify.
Invoke the deleteUser API to delete a user from the Auth category. This action will also sign your user out.
If your application uses a Cognito User Pool, which is the default configuration for the Amazon Cognito plugin, this action will delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone.
func deleteUser() async { do { try await Amplify.Auth.deleteUser() print("Successfully deleted user") } catch let error as AuthError { print("Delete user failed with error \(error)") } catch { print("Unexpected error: \(error)") }}func deleteUser() -> AnyCancellable { Amplify.Publisher.create { try await Amplify.Auth.deleteUser() }.sink { if case let .failure(authError) = $0 { print("Delete user failed with error \(authError)") } } receiveValue: { print("Successfully deleted user") }}