Add Mailchimp login to Next.js
A Next.js application needs Mailchimp as a social sign-in option.
Auth.js · Const
Mailchimp is a built-in Auth.js OAuth provider. Add it to the providers list and configure the documented Mailchimp credentials; Auth.js supplies default provider settings.
Mailchimp is a built-in OAuth provider. Add it to Auth.js's providers list; Auth.js uses the provider's default OAuth configuration, while client credentials are supplied through the documented environment variables or explicit provider configuration.
function default(config?: OAuthUserConfig<Record<string, any>>): OAuthConfig<Record<string, any>>| Name | Type | Description |
|---|---|---|
config | OAuthUserConfig<Record<string, any>> | Optional OAuth provider configuration, including values such as client ID and client secret. |
OAuthConfig<Record<string, any>>
AUTH_MAILCHIMP_ID and AUTH_MAILCHIMP_SECRET./api/auth/callback/mailchimp endpoint.import NextAuth from "next-auth"
import MailChimp from "next-auth/providers/mailchimp"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [MailChimp],
})Register the built-in Mailchimp provider in a Next.js Auth.js configuration, then set the provider credentials in the environment.
A Next.js application needs Mailchimp as a social sign-in option.
An integration needs credentials or OAuth settings that differ from the defaults.
A deployment is registering its OAuth redirect with Mailchimp.
Import the framework-specific Mailchimp provider and include it in the Auth.js providers array. In Next.js, the documented form is MailChimp passed directly as a provider.
Follow-up: How would you customize it? Use the provider function form and pass an OAuth user configuration, such as client credentials or other supported overrides.
The documented environment variables are AUTH_MAILCHIMP_ID and AUTH_MAILCHIMP_SECRET. Auth.js can infer the provider credentials from these names in the standard setup.
Follow-up: What must be changed for a nonstandard setup? Provide explicit clientId and clientSecret values in Mailchimp({ ... }) and override other defaults as needed.
For a Next.js deployment, configure the callback URL as https://example.com/api/auth/callback/mailchimp. The provider identifier in the path is mailchimp.
Follow-up: How does the callback path differ in other integrations? The page documents /auth/callback/mailchimp for Qwik and SvelteKit, while Express is not yet documented there.
OAuthConfigOAuthUserConfigprovidersMailChimpAuthAUTH_MAILCHIMP_IDAUTH_MAILCHIMP_SECRET