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

Choose your framework/language

Page updated Aug 7, 2024

Connect to AWS resources

Amplify client libraries provide you with the flexibility to directly connect your application to AWS resources such as AWS AppSync, Amazon Cognito, Amazon S3, and more.

To get started, client libraries must be configured. This is typically done by using the amplify_outputs.json file generated by the Amplify backend tooling, however using the client libraries does not require backend resources to be created by Amplify.

For JavaScript-based applications, the client library can be configured by using the generated outputs file:

src/main.ts
import { Amplify } from "aws-amplify"
import outputs from "../amplify_outputs.json"
Amplify.configure(outputs)

Or by configuring the library directly by passing a ResourcesConfig object. For example, to configure the client library for use with Amazon Cognito, specify the Auth configuration:

src/main.ts
import { Amplify } from "aws-amplify"
Amplify.configure({
Auth: {
Cognito: {
userPoolId: "<your-cognito-user-pool-id>",
userPoolClientId: "<your-cognito-user-pool-client-id>",
identityPoolId: "<your-cognito-identity-pool-id>",
loginWith: {
email: true,
},
signUpVerificationMethod: "code",
userAttributes: {
email: {
required: true,
},
},
allowGuestAccess: true,
passwordFormat: {
minLength: 8,
requireLowercase: true,
requireUppercase: true,
requireNumbers: true,
requireSpecialCharacters: true,
},
},
},
})

By configuring the client library, Amplify automates the communication with the underlying AWS resources, and provides a friendly API to author your business logic. In the snippet below, the signIn function does not require passing information from your Cognito resource to initiate the sign-in flow.

src/main.ts
import { signIn } from "aws-amplify/auth"
await signIn({
username: "john.doe@example.com",
password: "hunter2",
})

For more information about how to use the Amplify client libraries with existing AWS resources, visit the guides:

Connect to Cognito

Connect to Cognito resources using Amplify Auth's client library