Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Jun 7, 2024


For advanced use cases where Amplify does not provide the functionality, you can retrieve an escape hatch to access the underlying Amazon Cognito client.

Note: While the Amplify Library for Swift is production ready, please note that the underlying AWS SDK for Swift is currently in Developer Preview, and is not yet intended for production workloads. Here is additional reading material on the stability of the SDK.

The escape hatch provides access to the underlying AWSCognitoIdentityProvider instance. Import the necessary types:

import AWSCognitoAuthPlugin
import AWSCognitoIdentityProvider

Then retrieve the escape hatch with this code:

func getEscapeHatch() {
let client: CognitoIdentityProviderClient
// Get the instance of AWSCognitoAuthPlugin
let plugin = try? Amplify.Auth.getPlugin(for: "awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin
// Get the instance of CognitoIdentityProviderClient
if case .userPoolAndIdentityPool(let userPoolClient, _) = plugin?.getEscapeHatch() {
client = userPoolClient
} else if case .userPool(let userPoolClient) = plugin?.getEscapeHatch() {
client = userPoolClient
} else {
fatalError("No user pool configuration found")
print("Fetched escape hatch - \(String(describing: client))")