---
title: "Connect to existing AWS resources"
section: "frontend"
platforms: ["android", "angular", "flutter", "javascript", "nextjs", "react", "react-native", "swift", "vue"]
gen: 2
last-updated: "2026-09-28T14:05:06.000Z"
url: "https://docs.amplify.aws/react/frontend/connect-to-existing-resources/"
---

Amplify client libraries can be used **independently** without the Amplify backend workflow. If you've provisioned AWS resources with CDK, Terraform, CloudFormation, or the AWS Console, you can connect Amplify libraries directly to those resources.

This means you can adopt Amplify's client libraries for authentication, data, storage, and more, while keeping full control over your infrastructure.

## When to use this approach

- You already have AWS resources provisioned with **CDK**, **Terraform**, or **CloudFormation**
- You want to use Amplify client libraries without adopting the Amplify backend (`ampx`) workflow
- You need to connect to shared infrastructure managed by a platform team
- You want **programmatic control** over configuration for testing or environment switching

## How it works

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
The default path is a generated `amplify_outputs.json` file that you hand to `Amplify.configure()`:

```typescript
import { Amplify } from 'aws-amplify';
import outputs from './amplify_outputs.json';

Amplify.configure(outputs);
```

When you own the infrastructure there is no generated file, so you provide the configuration yourself. There are three ways to do that:

#### [Configuration builder]

`createConfigurationBuilder`, exported from `aws-amplify`, assembles a `ResourcesConfig` step by step. Every method returns the builder, and `build()` produces a frozen `ResourcesConfig` that `Amplify.configure()` accepts:

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .auth({
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456'
    }
  })
  .storage({ S3: { bucket: 'my-app-bucket', region: 'us-east-1' } })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

| Method | Description |
|--------|-------------|
| `from(seed)` | Merges an existing configuration in. Accepts anything `Amplify.configure()` accepts: a `ResourcesConfig`, a legacy `aws-exports` object, `amplify_outputs.json`, or **another builder**. Can be called repeatedly to accumulate, and is also available as `createConfigurationBuilder({ from })`. |
| `add(category, value)` | Adds a category, **replacing** it entirely if already present. |
| `patch(category, partial)` | Deep-merges a partial into a category, keeping nested values you don't mention. Creates the category if it doesn't exist. |
| `auth()`, `api()`, `storage()`, `analytics()`, `geo()`, `notifications()`, `interactions()`, `predictions()` | Shorthands for `add()` with that category: `.auth(config)` is `.add('Auth', config)`. |
| `build()` | Returns the finished, frozen `ResourcesConfig`. |

**Configure part of a configuration.** `patch()` deep-merges into a category, so you can change one nested value and leave the rest of it alone. This is the difference between the two write methods: `add('Auth', …)` (and its `auth()` shorthand) discards whatever `Auth` held, while `patch()` keeps it.

```typescript
const config = createConfigurationBuilder({ from: outputs })
  // Everything else under Auth.Cognito survives
  .patch('Auth', { Cognito: { userPoolId: 'us-east-1_dev123' } })
  // Add or overwrite a category outright, whether or not the outputs file carries it
  .add('Storage', { S3: { bucket: 'my-platform-bucket', region: 'us-east-1' } })
  .build();
```

**Extend a base builder.** A builder is itself a valid seed, so one shared base can produce environment-specific configurations without being mutated:

```typescript
// Owned by your platform team, never passed to configure() directly
const base = createConfigurationBuilder({ from: outputs });

const dev = createConfigurationBuilder({ from: base })
  .patch('Auth', { Cognito: { userPoolId: 'us-east-1_dev123' } })
  .build();

const prod = createConfigurationBuilder({ from: base })
  .patch('Auth', { Cognito: { userPoolId: 'us-east-1_prod789' } })
  .build();
```

**Write generators.** Because `build()` returns a plain object, a function that closes over the shared base turns a single varying value into a whole configuration:

```typescript
const withUserPool = (userPoolId: string) =>
  createConfigurationBuilder({ from: base })
    .patch('Auth', { Cognito: { userPoolId } })
    .build();

Amplify.configure(withUserPool('us-east-1_dev123'));
```

#### [Manual configuration]

Pass a `ResourcesConfig` object straight to `Amplify.configure()`. Nothing is merged for you, so every call states the complete configuration:

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
      loginWith: {
        email: true
      }
    }
  },
  Storage: {
    S3: {
      bucket: 'my-app-bucket',
      region: 'us-east-1'
    }
  }
});
```

This is the most direct option when your app has exactly one configuration and it never varies at runtime.

#### [Handwritten definition]

Keep the configuration in a file of your own and import it, the way a generated `amplify_outputs.json` is imported. Amplify only cares about the shape, so the file name is yours to choose. See the [full `amplify_outputs.json` specification](/[platform]/reference/amplify_outputs/) for every supported field:

```json title="my_resources.json"
{
  "version": "1.5",
  "auth": {
    "aws_region": "us-east-1",
    "user_pool_id": "us-east-1_abc123",
    "user_pool_client_id": "abcdef123456"
  },
  "storage": {
    "aws_region": "us-east-1",
    "bucket_name": "my-app-bucket"
  }
}
```

```typescript
import { Amplify, createAmplifyContext } from 'aws-amplify';
import resources from './my_resources.json';

Amplify.configure(resources);
// or
const ctx = createAmplifyContext(resources);
```

Because the file is checked in as data, this option keeps the configuration out of your application code while still letting you hold several of them: one file per environment, each imported where it is needed.

The built `ResourcesConfig` is a plain object either way, so it works anywhere a configuration is accepted: pass it to `Amplify.configure()` to set it globally, or to `createAmplifyContext()` to create an isolated [local context](/[platform]/frontend/local-context/) instead of touching global state.
<!-- /Platform -->

<!-- Platform: swift -->
There are two ways to configure Amplify client libraries with your own resources:

### Option 1: Manual `amplify_outputs.json`

Create an `amplify_outputs.json` file in your Xcode project. See the [full specification](/[platform]/reference/amplify_outputs/) for all supported fields.

```json title="amplify_outputs.json"
{
  "version": "1.5",
  "auth": {
    "aws_region": "us-east-1",
    "user_pool_id": "us-east-1_abc123",
    "user_pool_client_id": "abcdef123456",
    "identity_pool_id": "us-east-1:11111111-2222-3333-4444-555555555555"
  }
}
```

Then configure Amplify as usual:

```swift
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure(with: .amplifyOutputs)
```

### Option 2: Programmatic configuration with `AmplifyOutputsData`

Build the configuration in code without any JSON files:

```swift
import Amplify
import AWSCognitoAuthPlugin

let config = AmplifyOutputsData(
    auth: .init(
        awsRegion: "us-east-1",
        userPoolId: "us-east-1_abc123",
        userPoolClientId: "abcdef123456"
    )
)

try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure(config)
```

This approach is ideal for:
- **Unit testing:** Configure Amplify without bundling JSON files
- **Environment switching:** Build different configurations for dev/staging/prod
- **Dynamic configuration:** Fetch configuration from a remote source at runtime
<!-- /Platform -->

<!-- Platform: android -->
There are two ways to configure Amplify client libraries with your own resources:

### Option 1: Manual `amplify_outputs.json`

Create an `amplify_outputs.json` file in your `app/src/main/res/raw/` directory. See the [full specification](/[platform]/reference/amplify_outputs/) for all supported fields.

```json title="amplify_outputs.json"
{
  "version": "1.5",
  "auth": {
    "aws_region": "us-east-1",
    "user_pool_id": "us-east-1_abc123",
    "user_pool_client_id": "abcdef123456",
    "identity_pool_id": "us-east-1:11111111-2222-3333-4444-555555555555"
  }
}
```

Then configure Amplify as usual:

```kotlin
Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.configure(applicationContext)
```

### Option 2: Programmatic configuration with `AmplifyOutputsData`

Build the configuration in code without any JSON files:

```kotlin
import com.amplifyframework.core.Amplify
import com.amplifyframework.core.configuration.AmplifyOutputsData
import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin

val config = AmplifyOutputsData(
    auth = Auth(
        awsRegion = "us-east-1",
        userPoolId = "us-east-1_abc123",
        userPoolClientId = "abcdef123456"
    )
)

Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.configure(config, applicationContext)
```

This approach is ideal for:
- **Unit testing:** Configure Amplify without bundling JSON files
- **Environment switching:** Build different configurations for dev/staging/prod
- **Dynamic configuration:** Fetch configuration from a remote source at runtime
<!-- /Platform -->

<!-- Platform: flutter -->
There are two ways to configure Amplify client libraries with your own resources:

### Option 1: Manual `amplify_outputs.json`

Create an `amplify_outputs.json` file with your resource configuration. See the [full specification](/[platform]/reference/amplify_outputs/) for all supported fields.

```json title="amplify_outputs.json"
{
  "version": "1.5",
  "auth": {
    "aws_region": "us-east-1",
    "user_pool_id": "us-east-1_abc123",
    "user_pool_client_id": "abcdef123456",
    "identity_pool_id": "us-east-1:11111111-2222-3333-4444-555555555555"
  }
}
```

Then generate the Dart configuration and configure Amplify:

```bash
npx ampx generate outputs --outputs-format dart --outputs-out-dir lib
```

```dart
import 'amplify_outputs.dart';

await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(amplifyConfig);
```

### Option 2: Programmatic configuration with `AmplifyOutputs`

Build the configuration in code without any files:

```dart
import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';

final config = AmplifyOutputs(
  auth: AuthOutputs(
    awsRegion: 'us-east-1',
    userPoolId: 'us-east-1_abc123',
    userPoolClientId: 'abcdef123456',
  ),
);

await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(config);
```

This approach is ideal for:
- **Unit testing:** Configure Amplify without bundling files
- **Environment switching:** Build different configurations for dev/staging/prod
- **Dynamic configuration:** Fetch configuration from a remote source at runtime
<!-- /Platform -->

## Configure Auth (Amazon Cognito)

Connect to an existing Cognito User Pool and Identity Pool.

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .auth({
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
      loginWith: {
        email: true
      },
      signUpVerificationMethod: 'code',
      userAttributes: {
        email: { required: true }
      },
      allowGuestAccess: true,
      passwordFormat: {
        minLength: 8,
        requireLowercase: true,
        requireUppercase: true,
        requireNumbers: true,
        requireSpecialCharacters: true
      }
    }
  })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
      loginWith: {
        email: true
      },
      signUpVerificationMethod: 'code',
      userAttributes: {
        email: { required: true }
      },
      allowGuestAccess: true,
      passwordFormat: {
        minLength: 8,
        requireLowercase: true,
        requireUppercase: true,
        requireNumbers: true,
        requireSpecialCharacters: true
      }
    }
  }
});
```

<!-- /Platform -->

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    auth: .init(
        awsRegion: "us-east-1",
        userPoolId: "us-east-1_abc123",
        userPoolClientId: "abcdef123456",
        identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555",
        passwordPolicy: .init(
            minLength: 8,
            requireNumbers: true,
            requireLowercase: true,
            requireUppercase: true,
            requireSymbols: false
        ),
        oauth: .init(
            identityProviders: ["GOOGLE", "SIGN_IN_WITH_APPLE"],
            domain: "myapp.auth.us-east-1.amazoncognito.com",
            scopes: ["openid", "email", "profile"],
            redirectSignInUri: ["myapp://callback"],
            redirectSignOutUri: ["myapp://signout"],
            responseType: "code"
        ),
        standardRequiredAttributes: [.email],
        usernameAttributes: [.email],
        userVerificationTypes: [.email],
        unauthenticatedIdentitiesEnabled: true,
        mfaConfiguration: "OPTIONAL",
        mfaMethods: ["SMS", "TOTP"]
    )
)

try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    auth = Auth(
        awsRegion = "us-east-1",
        userPoolId = "us-east-1_abc123",
        userPoolClientId = "abcdef123456",
        identityPoolId = "us-east-1:11111111-2222-3333-4444-555555555555",
        passwordPolicy = Auth.PasswordPolicy(
            minLength = 8,
            requireNumbers = true,
            requireLowercase = true,
            requireUppercase = true,
            requireSymbols = false
        ),
        oauth = Auth.Oauth(
            identityProviders = listOf(
                IdentityProviders.GOOGLE,
                IdentityProviders.SIGN_IN_WITH_APPLE
            ),
            domain = "myapp.auth.us-east-1.amazoncognito.com",
            scopes = listOf("openid", "email", "profile"),
            redirectSignInUri = listOf("myapp://callback"),
            redirectSignOutUri = listOf("myapp://signout"),
            responseType = ResponseType.Code
        ),
        standardRequiredAttributes = listOf(
            AmazonCognitoStandardAttributes.EMAIL
        ),
        usernameAttributes = listOf(
            UsernameAttributes.EMAIL
        ),
        userVerificationTypes = listOf(
            VerificationMechanism.EMAIL
        ),
        unauthenticatedIdentitiesEnabled = true,
        mfaConfiguration = MfaConfiguration.OPTIONAL,
        mfaMethods = listOf(
            MfaMethods.SMS,
            MfaMethods.TOTP
        )
    )
)

Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```dart
final config = AmplifyOutputs(
  auth: AuthOutputs(
    awsRegion: 'us-east-1',
    userPoolId: 'us-east-1_abc123',
    userPoolClientId: 'abcdef123456',
    identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
    passwordPolicy: PasswordPolicy(
      minLength: 8,
      requireNumbers: true,
      requireLowercase: true,
      requireUppercase: true,
      requireSymbols: false,
    ),
    oauth: OAuthOutputs(
      identityProviders: [IdentityProvider.google, IdentityProvider.apple],
      domain: 'myapp.auth.us-east-1.amazoncognito.com',
      scopes: ['openid', 'email', 'profile'],
      redirectSignInUri: ['myapp://callback'],
      redirectSignOutUri: ['myapp://signout'],
      responseType: 'code',
    ),
    standardRequiredAttributes: [CognitoStandardAttribute.email],
    usernameAttributes: [UsernameAttribute.email],
    userVerificationTypes: [VerificationType.email],
    unauthenticatedIdentitiesEnabled: true,
    mfaConfiguration: MfaEnforcement.optional,
    mfaMethods: [MfaMethod.sms, MfaMethod.totp],
  ),
);

await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(config);
```
<!-- /Platform -->

### Auth required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['Auth']`, the object both tabs above build:

| Field | Required | Description |
|-------|----------|-------------|
| `Cognito.userPoolId` | With a user pool | Cognito User Pool ID |
| `Cognito.userPoolClientId` | With a user pool | Cognito app client ID |
| `Cognito.identityPoolId` | With an identity pool | Cognito Identity Pool ID, needed for guest access and for IAM-signed requests |

There is no region field: the region is read from the user pool and identity pool IDs. `Cognito` accepts the user pool fields, the identity pool fields, or both, so an identity-pool-only configuration cannot carry `userPoolId`.

Every other field is optional. See [`AuthConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/Auth/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, android, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | Yes | AWS region (e.g. `us-east-1`) |
| `userPoolId` | Yes | Cognito User Pool ID |
| `userPoolClientId` | Yes | Cognito app client ID |

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

## Configure Data (AWS AppSync)

Connect to an existing AppSync GraphQL API.

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .api({
    GraphQL: {
      endpoint:
        'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
      region: 'us-east-1',
      apiKey: 'da2-abcdefghijklmno',
      defaultAuthMode: 'apiKey'
    }
  })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  API: {
    GraphQL: {
      endpoint:
        'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
      region: 'us-east-1',
      apiKey: 'da2-abcdefghijklmno',
      defaultAuthMode: 'apiKey'
    }
  }
});
```

> **Info:** In a `ResourcesConfig` object the AppSync API lives under `API.GraphQL`, and `defaultAuthMode` takes the client-side value, one of `apiKey`, `userPool`, `identityPool`, `oidc`, `lambda`, or `none`, rather than the `API_KEY` style used in `amplify_outputs.json`.
<!-- /Platform -->

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    data: .init(
        awsRegion: "us-east-1",
        url: "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql",
        apiKey: "da2-abcdefghijklmno",
        defaultAuthorizationType: .apiKey,
        authorizationTypes: [.apiKey, .amazonCognitoUserPools]
    )
)

try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    data = Data(
        awsRegion = "us-east-1",
        url = "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql",
        apiKey = "da2-abcdefghijklmno",
        defaultAuthorizationType = AwsAppsyncAuthorizationType.API_KEY,
        authorizationTypes = listOf(
            AwsAppsyncAuthorizationType.API_KEY,
            AwsAppsyncAuthorizationType.AMAZON_COGNITO_USER_POOLS
        )
    )
)

Amplify.addPlugin(AWSApiPlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```dart
final config = AmplifyOutputs(
  data: DataOutputs(
    awsRegion: 'us-east-1',
    url: 'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
    apiKey: 'da2-abcdefghijklmno',
    defaultAuthorizationType: AuthorizationType.apiKey,
    authorizationTypes: [AuthorizationType.apiKey, AuthorizationType.userPools],
  ),
);

await Amplify.addPlugin(AmplifyAPI());
await Amplify.configure(config);
```
<!-- /Platform -->

### Data required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['API']`, the object both tabs above build:

| Field | Required | Description |
|-------|----------|-------------|
| `GraphQL.endpoint` | Yes | AppSync GraphQL endpoint URL |
| `GraphQL.defaultAuthMode` | Yes | `apiKey`, `userPool`, `identityPool`, `oidc`, `lambda`, or `none`. `iam` is the deprecated spelling of `identityPool` |
| `GraphQL.apiKey` | With `apiKey` auth | AppSync API key |
| `GraphQL.region` | With `identityPool` auth | Region used to sign the request |

Every other field is optional. See [`APIConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/API/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, android, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | Yes | AWS region |
| `url` | Yes | AppSync GraphQL endpoint URL |
| `defaultAuthorizationType` | Yes | Default auth mode: API key, Cognito user pools, IAM, Lambda, or OIDC |
| `authorizationTypes` | Yes | Every auth mode the API accepts, from the same list |
| `apiKey` | With API key auth | AppSync API key |

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

## Configure Storage (Amazon S3)

Connect to an existing S3 bucket.

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .auth({
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555'
    }
  })
  .storage({ S3: { bucket: 'my-app-bucket', region: 'us-east-1' } })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555'
    }
  },
  Storage: {
    S3: {
      bucket: 'my-app-bucket',
      region: 'us-east-1'
    }
  }
});
```

### Multiple buckets

#### [Configuration builder]

```typescript
const config = createConfigurationBuilder()
  .storage({
    S3: {
      bucket: 'primary-bucket',
      region: 'us-east-1',
      buckets: {
        media: { bucketName: 'my-media-bucket', region: 'us-east-1' },
        logs: { bucketName: 'my-logs-bucket', region: 'us-west-2' }
      }
    }
  })
  .build();
```

#### [Manual configuration]

```typescript
Amplify.configure({
  Storage: {
    S3: {
      bucket: 'primary-bucket',
      region: 'us-east-1',
      buckets: {
        media: { bucketName: 'my-media-bucket', region: 'us-east-1' },
        logs: { bucketName: 'my-logs-bucket', region: 'us-west-2' }
      }
    }
  }
});
```

<!-- /Platform -->

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    auth: .init(
        awsRegion: "us-east-1",
        userPoolId: "us-east-1_abc123",
        userPoolClientId: "abcdef123456",
        identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555"
    ),
    storage: .init(
        awsRegion: "us-east-1",
        bucketName: "my-app-bucket"
    )
)

try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSS3StoragePlugin())
try Amplify.configure(config)
```

### Multiple buckets

```swift
let config = AmplifyOutputsData(
    storage: .init(
        awsRegion: "us-east-1",
        bucketName: "primary-bucket",
        buckets: [
            .init(name: "media", bucketName: "my-media-bucket", awsRegion: "us-east-1"),
            .init(name: "logs", bucketName: "my-logs-bucket", awsRegion: "us-west-2")
        ]
    )
)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    auth = Auth(
        awsRegion = "us-east-1",
        userPoolId = "us-east-1_abc123",
        userPoolClientId = "abcdef123456",
        identityPoolId = "us-east-1:11111111-2222-3333-4444-555555555555"
    ),
    storage = Storage(
        awsRegion = "us-east-1",
        bucketName = "my-app-bucket"
    )
)

Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.addPlugin(AWSS3StoragePlugin())
Amplify.configure(config, applicationContext)
```

### Multiple buckets

```kotlin
val config = AmplifyOutputsData(
    storage = Storage(
        awsRegion = "us-east-1",
        bucketName = "primary-bucket",
        buckets = listOf(
            Storage.Bucket(
                name = "media",
                bucketName = "my-media-bucket",
                awsRegion = "us-east-1"
            ),
            Storage.Bucket(
                name = "logs",
                bucketName = "my-logs-bucket",
                awsRegion = "us-west-2"
            )
        )
    )
)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```dart
final config = AmplifyOutputs(
  auth: AuthOutputs(
    awsRegion: 'us-east-1',
    userPoolId: 'us-east-1_abc123',
    userPoolClientId: 'abcdef123456',
    identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
  ),
  storage: StorageOutputs(
    awsRegion: 'us-east-1',
    bucketName: 'my-app-bucket',
  ),
);

await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.addPlugin(AmplifyStorageS3());
await Amplify.configure(config);
```

### Multiple buckets

```dart
final config = AmplifyOutputs(
  storage: StorageOutputs(
    awsRegion: 'us-east-1',
    bucketName: 'primary-bucket',
    buckets: [
      BucketOutputs(name: 'media', bucketName: 'my-media-bucket', awsRegion: 'us-east-1'),
      BucketOutputs(name: 'logs', bucketName: 'my-logs-bucket', awsRegion: 'us-west-2'),
    ],
  ),
);
```
<!-- /Platform -->

> **Info:** Storage requires Auth (Cognito Identity Pool) for authorization. Always configure Auth alongside Storage.

### Storage required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['Storage']`, the object both tabs above build:

| Field | Required | Description |
|-------|----------|-------------|
| `S3.bucket` | For the default bucket | Bucket used by calls that do not name one |
| `S3.region` | For the default bucket | Region of that bucket |
| `S3.buckets[name].bucketName`, `S3.buckets[name].region` | With additional buckets | Each extra bucket is keyed by the friendly name you pass to the Storage APIs |

Every other field is optional. See [`StorageConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/Storage/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, android, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | Yes | AWS region |
| `bucketName` | Yes | Default S3 bucket name |
| `buckets[].name`, `buckets[].bucketName`, `buckets[].awsRegion` | With additional buckets | All three are required on every entry |

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

## Configure Analytics (Amazon Pinpoint)

Connect to an existing Pinpoint application.

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .analytics({
    Pinpoint: {
      appId: 'abc123def456',
      region: 'us-east-1'
    }
  })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Analytics: {
    Pinpoint: {
      appId: 'abc123def456',
      region: 'us-east-1'
    }
  }
});
```

<!-- /Platform -->

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    analytics: .init(
        amazonPinpoint: .init(
            awsRegion: "us-east-1",
            appId: "abc123def456"
        )
    )
)

try Amplify.add(plugin: AWSPinpointAnalyticsPlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    analytics = Analytics(
        amazonPinpoint = Analytics.AmazonPinpoint(
            awsRegion = "us-east-1",
            appId = "abc123def456"
        )
    )
)

Amplify.addPlugin(AWSPinpointAnalyticsPlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```dart
final config = AmplifyOutputs(
  analytics: AnalyticsOutputs(
    amazonPinpoint: AmazonPinpointOutputs(
      awsRegion: 'us-east-1',
      appId: 'abc123def456',
    ),
  ),
);

await Amplify.addPlugin(AmplifyAnalyticsPinpoint());
await Amplify.configure(config);
```
<!-- /Platform -->

### Analytics required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['Analytics']`, the object both tabs above build:

| Field | Required | Description |
|-------|----------|-------------|
| `Pinpoint.appId` | Yes | Pinpoint application (project) ID |
| `Pinpoint.region` | Yes | Region of the Pinpoint project |

Every other field is optional. See [`AnalyticsConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/Analytics/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, android, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `amazonPinpoint.awsRegion` | Yes | AWS region of the Pinpoint project |
| `amazonPinpoint.appId` | Yes | Pinpoint application (project) ID |

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

## Configure Geo (Amazon Location Service)

Connect to existing Location Service resources.

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .geo({
    LocationService: {
      region: 'us-east-1',
      maps: {
        items: { myMap: { style: 'VectorEsriStreets' } },
        default: 'myMap'
      },
      searchIndices: {
        items: ['myPlaceIndex'],
        default: 'myPlaceIndex'
      },
      geofenceCollections: {
        items: ['myGeofenceCollection'],
        default: 'myGeofenceCollection'
      }
    }
  })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Geo: {
    LocationService: {
      region: 'us-east-1',
      maps: {
        items: { myMap: { style: 'VectorEsriStreets' } },
        default: 'myMap'
      },
      searchIndices: {
        items: ['myPlaceIndex'],
        default: 'myPlaceIndex'
      },
      geofenceCollections: {
        items: ['myGeofenceCollection'],
        default: 'myGeofenceCollection'
      }
    }
  }
});
```

<!-- /Platform -->

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    geo: .init(
        awsRegion: "us-east-1",
        maps: .init(
            items: ["myMap": .init(style: "VectorEsriStreets")],
            default: "myMap"
        ),
        searchIndices: .init(
            items: ["myPlaceIndex"],
            default: "myPlaceIndex"
        ),
        geofenceCollections: .init(
            items: ["myGeofenceCollection"],
            default: "myGeofenceCollection"
        )
    )
)

try Amplify.add(plugin: AWSLocationGeoPlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    geo = Geo(
        awsRegion = "us-east-1",
        maps = Geo.Maps(
            items = mapOf(
                "myMap" to AmazonLocationServiceConfig(
                    style = "VectorEsriStreets"
                )
            ),
            default = "myMap"
        ),
        searchIndices = Geo.SearchIndices(
            items = listOf("myPlaceIndex"),
            default = "myPlaceIndex"
        ),
        geofenceCollections = Geo.GeofenceCollections(
            items = listOf("myGeofenceCollection"),
            default = "myGeofenceCollection"
        )
    )
)

Amplify.addPlugin(AWSLocationGeoPlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

### Geo required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['Geo']`, the object both tabs above build:

| Field | Required | Description |
|-------|----------|-------------|
| `LocationService.region` | Yes | Region of the Location Service resources |
| `LocationService.maps.items`, `LocationService.maps.default` | With `maps` | Maps keyed by name, plus the default map name |
| `LocationService.searchIndices.items`, `LocationService.searchIndices.default` | With `searchIndices` | Place index names, plus the default index |
| `LocationService.geofenceCollections.items`, `LocationService.geofenceCollections.default` | With `geofenceCollections` | Collection names, plus the default collection |

Every other field is optional. See [`GeoConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/Geo/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, android, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | Yes | AWS region of the Location Service resources |
| `maps.items`, `maps.default` | With `maps` | Maps keyed by name, plus the default map name |
| `searchIndices.items`, `searchIndices.default` | With `searchIndices` | Place index names, plus the default index |
| `geofenceCollections.items`, `geofenceCollections.default` | With `geofenceCollections` | Collection names, plus the default collection |

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

Each resource group is optional on its own, but configure the ones your app actually calls: the Geo APIs need a default for the resource type they use.

## Configure Notifications (Push)

Connect to an existing Pinpoint application for push notifications.

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    notifications: .init(
        awsRegion: "us-east-1",
        amazonPinpointAppId: "abc123def456",
        channels: [.apns, .fcm, .inAppMessaging]
    )
)

try Amplify.add(plugin: AWSPinpointPushNotificationsPlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    notifications = Notifications(
        awsRegion = "us-east-1",
        amazonPinpointAppId = "abc123def456",
        channels = listOf(
            AmazonPinpointChannels.FCM,
            AmazonPinpointChannels.IN_APP_MESSAGING
        )
    )
)

Amplify.addPlugin(AWSPinpointPushNotificationsPlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```json title="amplify_outputs.json"
{
  "version": "1.5",
  "notifications": {
    "aws_region": "us-east-1",
    "amazon_pinpoint_app_id": "abc123def456",
    "channels": ["APNS", "FCM", "IN_APP_MESSAGING"]
  }
}
```
<!-- /Platform -->

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .notifications({
    PushNotification: {
      Pinpoint: { appId: 'abc123def456', region: 'us-east-1' }
    },
    InAppMessaging: {
      Pinpoint: { appId: 'abc123def456', region: 'us-east-1' }
    }
  })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Notifications: {
    PushNotification: {
      Pinpoint: { appId: 'abc123def456', region: 'us-east-1' }
    },
    InAppMessaging: {
      Pinpoint: { appId: 'abc123def456', region: 'us-east-1' }
    }
  }
});
```

<!-- /Platform -->

### Notifications required fields

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Fields of `ResourcesConfig['Notifications']`, the object both tabs above build. At least one of `PushNotification` and `InAppMessaging` must be present:

| Field | Required | Description |
|-------|----------|-------------|
| `PushNotification.Pinpoint.appId`, `PushNotification.Pinpoint.region` | For Pinpoint push | Pinpoint project backing push device registration |
| `PushNotification.CustomerProfiles.endpoint`, `PushNotification.CustomerProfiles.region` | For Amazon Connect push | Amazon Connect Customer Profiles endpoint backing push device registration |
| `InAppMessaging.Pinpoint.appId`, `InAppMessaging.Pinpoint.region` | For in-app messaging | Pinpoint project backing in-app messages |

Every other field is optional. See [`NotificationsConfig`](https://github.com/aws-amplify/amplify-js/blob/aws-amplify%406.22.0/packages/core/src/singleton/Notifications/types.ts) for the full type.
<!-- /Platform -->

<!-- Platform: swift, flutter -->
| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | For Pinpoint | AWS region of the Pinpoint project |
| `amazonPinpointAppId` | For Pinpoint | Pinpoint application ID |
| `channels` | For Pinpoint | Channels to enable: APNS, FCM, in-app messaging, email, or SMS. At least one entry, no duplicates |

A Pinpoint setup needs all three: the region, the app ID, and at least one channel.

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

<!-- Platform: android -->
Configure either a Pinpoint project or an Amazon Connect endpoint, or both:

| Field | Required | Description |
|-------|----------|-------------|
| `awsRegion` | For Pinpoint | AWS region of the Pinpoint project |
| `amazonPinpointAppId` | For Pinpoint | Pinpoint application ID |
| `channels` | For Pinpoint | Channels to enable: APNS, FCM, in-app messaging, email, or SMS. At least one entry, no duplicates |
| `amazonConnect.awsRegion`, `amazonConnect.endpoint` | For Amazon Connect | Amazon Connect Customer Profiles endpoint backing push device registration. Both are required on the entry |

A Pinpoint setup needs all three Pinpoint fields: the region, the app ID, and at least one channel.

Every other field is optional. See the [`amplify_outputs.json` schema](https://github.com/aws-amplify/amplify-backend/blob/%40aws-amplify%2Fclient-config%401.11.1/packages/client-config/src/client-config-schema/schema_v1.5.json) for the full shape.
<!-- /Platform -->

<!-- Platform: angular, javascript, nextjs, react, react-native, vue -->
In a `ResourcesConfig` object there is no `channels` list: which channels are active follows from the providers you configure, `PushNotification` and `InAppMessaging`. The `amazon_connect` block in `amplify_outputs.json` becomes `Notifications.PushNotification.CustomerProfiles` with `endpoint` and `region`.
<!-- /Platform -->

## Multi-category configuration

You can configure multiple services together. This example sets up Auth, Data, and Storage in a single configuration.

<!-- Platform: swift -->
```swift
let config = AmplifyOutputsData(
    auth: .init(
        awsRegion: "us-east-1",
        userPoolId: "us-east-1_abc123",
        userPoolClientId: "abcdef123456",
        identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555"
    ),
    data: .init(
        awsRegion: "us-east-1",
        url: "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql",
        defaultAuthorizationType: .amazonCognitoUserPools,
        authorizationTypes: [.amazonCognitoUserPools, .awsIAM]
    ),
    storage: .init(
        awsRegion: "us-east-1",
        bucketName: "my-app-bucket"
    )
)

try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.add(plugin: AWSS3StoragePlugin())
try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
```kotlin
val config = AmplifyOutputsData(
    auth = Auth(
        awsRegion = "us-east-1",
        userPoolId = "us-east-1_abc123",
        userPoolClientId = "abcdef123456",
        identityPoolId = "us-east-1:11111111-2222-3333-4444-555555555555"
    ),
    data = Data(
        awsRegion = "us-east-1",
        url = "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql",
        defaultAuthorizationType = AwsAppsyncAuthorizationType.AMAZON_COGNITO_USER_POOLS,
        authorizationTypes = listOf(
            AwsAppsyncAuthorizationType.AMAZON_COGNITO_USER_POOLS,
            AwsAppsyncAuthorizationType.AWS_IAM
        )
    ),
    storage = Storage(
        awsRegion = "us-east-1",
        bucketName = "my-app-bucket"
    )
)

Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.addPlugin(AWSApiPlugin())
Amplify.addPlugin(AWSS3StoragePlugin())
Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
```dart
final config = AmplifyOutputs(
  auth: AuthOutputs(
    awsRegion: 'us-east-1',
    userPoolId: 'us-east-1_abc123',
    userPoolClientId: 'abcdef123456',
    identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555',
  ),
  data: DataOutputs(
    awsRegion: 'us-east-1',
    url: 'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
    defaultAuthorizationType: AuthorizationType.userPools,
    authorizationTypes: [AuthorizationType.userPools, AuthorizationType.iam],
  ),
  storage: StorageOutputs(
    awsRegion: 'us-east-1',
    bucketName: 'my-app-bucket',
  ),
);

await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.addPlugin(AmplifyAPI());
await Amplify.addPlugin(AmplifyStorageS3());
await Amplify.configure(config);
```
<!-- /Platform -->

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->

#### [Configuration builder]

```typescript
import { Amplify, createAmplifyContext, createConfigurationBuilder } from 'aws-amplify';

const config = createConfigurationBuilder()
  .auth({
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555'
    }
  })
  .api({
    GraphQL: {
      endpoint:
        'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
      region: 'us-east-1',
      defaultAuthMode: 'userPool'
    }
  })
  .storage({ S3: { bucket: 'my-app-bucket', region: 'us-east-1' } })
  .build();

Amplify.configure(config);
// or
const ctx = createAmplifyContext(config);
```

Chaining also means a category can come from somewhere else entirely: seed the builder with a shared configuration and add only what this app owns.

#### [Manual configuration]

```typescript
import { Amplify } from 'aws-amplify';

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: 'us-east-1_abc123',
      userPoolClientId: 'abcdef123456',
      identityPoolId: 'us-east-1:11111111-2222-3333-4444-555555555555'
    }
  },
  API: {
    GraphQL: {
      endpoint:
        'https://abc123.appsync-api.us-east-1.amazonaws.com/graphql',
      region: 'us-east-1',
      defaultAuthMode: 'userPool'
    }
  },
  Storage: {
    S3: {
      bucket: 'my-app-bucket',
      region: 'us-east-1'
    }
  }
});
```

<!-- /Platform -->

<!-- Platform: swift -->
## Inspecting resolved configuration

You can inspect the configuration resolved from `amplify_outputs.json`:

```swift
let outputs = try AmplifyOutputs.amplifyOutputs.resolveConfiguration()

if let auth = outputs.auth {
    print("User Pool ID: \(auth.userPoolId)")
    print("Region: \(auth.awsRegion)")
    print("Identity Pool: \(auth.identityPoolId ?? "none")")
}

if let storage = outputs.storage {
    print("Bucket: \(storage.bucketName)")
    print("Additional buckets: \(storage.buckets?.count ?? 0)")
}

if let data = outputs.data {
    print("GraphQL endpoint: \(data.url)")
    print("Default auth: \(data.defaultAuthorizationType)")
}
```
<!-- /Platform -->

## Environment-specific configuration

<!-- Platform: swift -->
Switch between dev, staging, and production without separate JSON files:

```swift
let region: String
let userPoolId: String
let clientId: String

switch environment {
case .dev:
    region = "us-east-1"
    userPoolId = "us-east-1_dev123"
    clientId = "devClient123"
case .staging:
    region = "us-west-2"
    userPoolId = "us-west-2_staging456"
    clientId = "stagingClient456"
case .prod:
    region = "us-east-1"
    userPoolId = "us-east-1_prod789"
    clientId = "prodClient789"
}

let config = AmplifyOutputsData(
    auth: .init(
        awsRegion: region,
        userPoolId: userPoolId,
        userPoolClientId: clientId
    )
)

try Amplify.configure(config)
```
<!-- /Platform -->

<!-- Platform: android -->
Switch between dev, staging, and production without separate JSON files:

```kotlin
val (region, userPoolId, clientId) = when (BuildConfig.BUILD_TYPE) {
    "debug" -> Triple("us-east-1", "us-east-1_dev123", "devClient123")
    "staging" -> Triple("us-west-2", "us-west-2_staging456", "stagingClient456")
    else -> Triple("us-east-1", "us-east-1_prod789", "prodClient789")
}

val config = AmplifyOutputsData(
    auth = Auth(
        awsRegion = region,
        userPoolId = userPoolId,
        userPoolClientId = clientId
    )
)

Amplify.configure(config, applicationContext)
```
<!-- /Platform -->

<!-- Platform: flutter -->
Switch between dev, staging, and production without separate files:

```dart
final environment = const String.fromEnvironment('ENV', defaultValue: 'dev');

final AuthOutputs authConfig;
switch (environment) {
  case 'prod':
    authConfig = AuthOutputs(
      awsRegion: 'us-east-1',
      userPoolId: 'us-east-1_prod789',
      userPoolClientId: 'prodClient789',
    );
  case 'staging':
    authConfig = AuthOutputs(
      awsRegion: 'us-west-2',
      userPoolId: 'us-west-2_staging456',
      userPoolClientId: 'stagingClient456',
    );
  default:
    authConfig = AuthOutputs(
      awsRegion: 'us-east-1',
      userPoolId: 'us-east-1_dev123',
      userPoolClientId: 'devClient123',
    );
}

final config = AmplifyOutputs(auth: authConfig);
await Amplify.configure(config);
```
<!-- /Platform -->

<!-- Platform: javascript, angular, nextjs, react, react-native, vue -->
Keep one configuration per environment and select it at startup. With the builder, derive each one from a shared base so only the differing fields are restated. The generator pattern from [How it works](#how-it-works) applies directly:

```typescript
import { Amplify, createConfigurationBuilder } from 'aws-amplify';
import outputs from './amplify_outputs.json';

const base = createConfigurationBuilder({ from: outputs });

const withUserPool = (userPoolId: string) =>
  createConfigurationBuilder({ from: base })
    .patch('Auth', { Cognito: { userPoolId } })
    .build();

const configs = {
  dev: withUserPool('us-east-1_dev123'),
  prod: withUserPool('us-east-1_prod789')
};

Amplify.configure(configs[selectedEnvironment]);
```

If the environments share nothing, keep a separate outputs file per environment instead:

```typescript
import devOutputs from './amplify_outputs.dev.json';
import prodOutputs from './amplify_outputs.prod.json';

const outputs = process.env.NODE_ENV === 'production' ? prodOutputs : devOutputs;
Amplify.configure(outputs);
```

### Several environments at the same time

`Amplify.configure()` sets one process-wide configuration, so selecting an environment this way means the whole app moves with it. To keep more than one environment live at once, pass each configuration to `createAmplifyContext()` instead of to `configure()`, then hand the resulting context to the category APIs:

```typescript
import { createAmplifyContext } from 'aws-amplify';

const environments = {
  dev: createAmplifyContext(withUserPool('us-east-1_dev123')),
  prod: createAmplifyContext(withUserPool('us-east-1_prod789'))
};
```

See [Local context](/[platform]/frontend/local-context/) for what a context isolates, how to use one, and why it is a client-side API.
<!-- /Platform -->

## `amplify_outputs.json` schema reference

For the full schema of all supported configuration fields, see the [amplify_outputs.json reference](/[platform]/reference/amplify_outputs/).
