Amplify JS API Documentation
    Preparing search index...

    Variable AmplifyConst

    Amplify: {
        clearCredentials(): Promise<void>;
        configure(
            resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown,
            libraryOptions?: LibraryOptions,
        ): void;
        fetchAuthSession(options?: FetchAuthSessionOptions): Promise<AuthSession>;
        getConfig(): ResourcesConfig;
        getTokens(
            options: FetchAuthSessionOptions,
        ): Promise<AuthTokens | undefined>;
    } = ...

    The Amplify singleton facade provides the v6-compatible, global-state configure() / getConfig() API. It builds a branded, frozen AmplifyContext, publishes it as the global context (so category APIs can be called without an explicit context argument), and dispatches the configure Hub event that side effects such as auth's OAuth listener depend on.

    Type Declaration

    • clearCredentials: function
      • Clears cached credentials in the global context.

        Returns Promise<void>

        If configure() has not been called yet.

    • configure: function
      • Configures Amplify with the resourceConfig and libraryOptions, publishing the resulting branded context as the global AmplifyContext.

        If libraryOptions is omitted on a reconfigure, the previously configured non-Auth libraryOptions are preserved (mirroring the previous singleton merge behavior); when provided they replace the previous ones. When resourceConfig.Auth is present and the caller does not supply libraryOptions.Auth, the default Cognito token/credentials providers are wired using cookie storage (ssr: true) or localStorage (default), and the singleton token provider's auth config is re-synced on every call so a reconfigure with a new userPoolId retargets token refresh.

        Parameters

        • resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown

          The ResourcesConfig object that is typically imported from the amplifyconfiguration.json / amplify_outputs.json file. It can also be an object literal created inline when calling Amplify.configure.

        • OptionallibraryOptions: LibraryOptions

          The LibraryOptions additional options for the library.

        Returns void

        import config from './amplifyconfiguration.json';

        Amplify.configure(config);
    • fetchAuthSession: function
    • getConfig: function
      • Returns the ResourcesConfig object passed in as the resourceConfig parameter when calling Amplify.configure.

        If configure() has not been called yet, this warns and returns an empty config object ({}) rather than throwing, preserving the historical pre-context singleton behavior that callers (and release-gating e2e tests) depend on.

        Returns ResourcesConfig

        An ResourcesConfig object.

    • getTokens: function
    import { Amplify } from 'aws-amplify';
    import config from './amplifyconfiguration.json';

    Amplify.configure(config);