aws-amplify
- Version 6.22.2
- Published
- 259 kB
- 8 dependencies
- Apache-2.0 license
Install
npm i aws-amplifyyarn add aws-amplifypnpm add aws-amplifyOverview
AWS Amplify is a JavaScript library for Frontend and mobile developers building cloud-enabled applications.
Index
Variables
Functions
Variables
variable Amplify
const Amplify: { configure( resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, libraryOptions?: LibraryOptions ): void; getConfig(): ResourcesConfig; fetchAuthSession(options?: FetchAuthSessionOptions): Promise<AuthSession>; clearCredentials(): Promise<void>; getTokens(options: FetchAuthSessionOptions): Promise<AuthTokens | undefined>;};The
Amplifysingleton facade provides the v6-compatible, global-stateconfigure()/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 theconfigureHub event that side effects such as auth's OAuth listener depend on.Example 1
import { Amplify } from 'aws-amplify';import config from './amplifyconfiguration.json';Amplify.configure(config);
Functions
function createAmplifyContext
createAmplifyContext: ( resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, libraryOptions?: LibraryOptions) => AmplifyContext;Creates a local, branded AmplifyContext from the given resource configuration.
Unlike
Amplify.configure(), the returned context is **not** set as the global context and no Hub events are dispatched. Category APIs that receive this context (as their first positional argument) will use it instead of the global one, enabling per-request context injection in server-side / multi-tenant scenarios.This is the
aws-amplify-level wrapper around `@aws-amplify/core`'s `createAmplifyContext`. The core factory intentionally does **not** inject default Cognito providers (it sits below@aws-amplify/authin the dependency graph); this wrapper closes that gap by resolving and injecting **factory-style, per-context** Cognito token/credentials providers when the caller does not supply their own. Because each call builds fresh provider instances, contexts created here do **not** share the process-wide singleton providers used byAmplify.configure()— two contexts remain isolated from one another.Storage behaviour mirrors
Amplify.configure(): tokens are persisted tolocalStorageby default, or to cookies when{ ssr: true }is set.Parameter resourceConfig
Back-end resource configuration (typed config, legacy
aws-exports, or Gen2amplify_outputs).Parameter libraryOptions
Optional library options (e.g. Auth token/credentials providers,
ssr).Returns
A branded, frozen AmplifyContext.
Example 1
import { createAmplifyContext } from 'aws-amplify';import outputs from './amplify_outputs.json';const ctx = createAmplifyContext(outputs);// Pass ctx explicitly to category APIs:await signIn(ctx, { username, password });
Package Files (3)
Dependencies (8)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/aws-amplify.
- Markdown[](https://www.jsdocs.io/package/aws-amplify)
- HTML<a href="https://www.jsdocs.io/package/aws-amplify"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2064 ms. - Missing or incorrect documentation? Open an issue for this package.
