Skip to content
Migrating from NextAuth.js v4? Read our migration guide.

Cognito Provider

Resources

Setup

Callback URL

https://example.com/api/auth/callback/cognito

Environment Variables

AUTH_COGNITO_ID
AUTH_COGNITO_SECRET
AUTH_COGNITO_ISSUER

Configuration

/auth.ts
import NextAuth from "next-auth"
import Cognito from "next-auth/providers/cognito"
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Cognito],
})

Notes

You need to select your AWS region to go the the Cognito dashboard.

The issuer is a URL, that looks like this: https://cognito-idp.{region} .amazonaws.com/{PoolId}, where PoolId is from General Settings in Cognito, not to be confused with the App Client ID.

Before you can set these settings, you must set up an Amazon Cognito hosted domain. The setting can be found in App Client/Edit Hosted UI.

⚠️

Make sure you select all the appropriate client settings or the OAuth flow will not work.

Auth.js © Balázs Orbán and Team - 2024