Next.js Slack login
Add Slack sign-in to a Next.js Auth.js application using the built-in provider.
Auth.js · Const
Auth.js provides a built-in Slack provider for adding Slack sign-in. Configure the Slack client credentials, register the HTTPS callback URL, and include Slack in the Auth.js provider list.
The Slack provider is a built-in OAuth/OIDC integration. Add it to the provider list, configure the Slack client credentials through the expected environment variables, and register the matching HTTPS callback URL in Slack.
Slack(options): OAuthConfig<P>AUTH_SLACK_ID and AUTH_SLACK_SECRET./api/auth/callback/slack.import NextAuth from "next-auth"
import Slack from "next-auth/providers/slack"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Slack],
})Register Slack as a built-in provider in the Auth.js configuration; the provider reads its client credentials from the documented environment variables.
Add Slack sign-in to a Next.js Auth.js application using the built-in provider.
Connect Slack authentication to another Auth.js integration by registering its framework-specific callback path.
Adapt the provider when the built-in OIDC-oriented defaults do not fit a deployment.
Import the framework-specific Slack provider and include it in the Auth.js providers array. For Next.js, the documented setup uses Slack directly and obtains credentials from AUTH_SLACK_ID and AUTH_SLACK_SECRET.
Follow-up: What callback URL must be registered? Use https://example.com/api/auth/callback/slack for Next.js; other integrations use the framework-specific callback path shown in the provider documentation.
Set AUTH_SLACK_ID and AUTH_SLACK_SECRET, then register the application callback URL in Slack. The Next.js callback path is /api/auth/callback/slack.
Follow-up: Why can local development fail even with correct credentials? Slack requires the redirect URL to use HTTPS, so use an HTTPS tunnel and configure the corresponding Auth.js URL.
The provider supplies defaults, so the normal setup only adds Slack to the provider list. If those defaults do not fit the application, use Auth.js's documented customization mechanism for built-in OAuth providers.
Follow-up: What protocol does the default provider configuration assume? It assumes OpenID Connect, which affects how a customized configuration should be designed.
SlackProfileOAuthConfigOAuthUserConfigcustomizing a built-in OAuth provider