Amplify JS API Documentation
    Preparing search index...

    Function fetchAuthSession

    • Fetch the auth session of the given AmplifyContext — e.g. the per-request context handed to an SSR runWithAmplifyServerContext operation — instead of the global context. This restores the pre-context v6 SSR calling pattern fetchAuthSession(contextSpec) (the deprecated ContextSpec type is an alias of AmplifyContext, so existing SSR code compiles unchanged).

      Parameters

      Returns Promise<AuthSession>

      Promise

      AuthError - Throws error when session information cannot be refreshed.

    • Fetch the auth session including the tokens and credentials if they are available. By default it will automatically refresh expired auth tokens if a valid refresh token is present. You can force a refresh of non-expired tokens with { forceRefresh: true } input.

      Parameters

      Returns Promise<AuthSession>

      Promise — before Amplify.configure() has run this resolves with an empty session (all fields undefined), matching the pre-context behavior.

      AuthError - Throws error when session information cannot be refreshed.