Notion sign-in
Users authenticate to an application with their Notion account.
Auth.js · Const
Auth.js includes a built-in Notion OAuth provider. Configure it with Notion credentials and a redirect URI, then register the matching callback URL.
The Notion provider adds Notion OAuth login to Auth.js. Configure it with the provider credentials and a redirect URI, then register the matching callback URL in the Auth.js setup.
Notion(options)| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<P> & AdditionalConfig | OAuth provider options, including credentials and the required redirect URI. |
OAuthConfig<P>
/api/auth/callback/notion.import NextAuth from "next-auth"
import Notion from "next-auth/providers/notion"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Notion({
clientId: process.env.AUTH_NOTION_ID,
clientSecret: process.env.AUTH_NOTION_SECRET,
redirectUri: process.env.AUTH_NOTION_REDIRECT_URI,
}),
],
})Registers Notion as an Auth.js provider and supplies the credentials and redirect URI required by Notion.
Users authenticate to an application with their Notion account.
An application needs OAuth credentials supplied through environment variables.
A deployment requires a non-default redirect endpoint.
Use the built-in Notion provider and pass clientId, clientSecret, and redirectUri to it. Register the corresponding callback URL with the Auth.js route.
Follow-up: Why is the redirect URI explicitly configured? Notion requires it when exchanging the authorization result for tokens.
The callback path is provider-specific and ends with /callback/notion; in a Next.js deployment, the documented example is /api/auth/callback/notion.
Follow-up: What must be changed for another base path? Register the same callback suffix under that deployment's configured Auth.js base path.
The provider is built in and already has default OAuth settings. Override those defaults by passing options to the provider function, such as credentials and the redirect URI.
Follow-up: How are custom options applied? Auth.js deeply merges provider-call options with the built-in defaults.
NotionProfileOAuthUserConfigOAuthConfigcustomizing a built-in OAuth provider