Next.js social login
Users sign in to a Next.js application with their LinkedIn accounts.
Auth.js · Const
Auth.js includes a built-in LinkedIn provider. Add it to the providers array and configure the LinkedIn client credentials with AUTH_LINKEDIN_ID and AUTH_LINKEDIN_SECRET.
LinkedIn is a built-in Auth.js provider. Add the imported provider to the Auth.js providers list; Auth.js reads the client credentials from AUTH_LINKEDIN_ID and AUTH_LINKEDIN_SECRET, then uses LinkedIn's OIDC-based defaults unless you override them.
LinkedIn(options?: OIDCUserConfig<P>)| Name | Type | Description |
|---|---|---|
options | OIDCUserConfig<P> | Provider options including LinkedIn client credentials when configuring the core provider factory explicitly. |
OIDCConfig<P>
import NextAuth from "next-auth"
import LinkedIn from "next-auth/providers/linkedin"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [LinkedIn],
})Register the built-in LinkedIn provider in a NextAuth configuration, with credentials supplied through the documented environment variables.
Users sign in to a Next.js application with their LinkedIn accounts.
An application needs a preconfigured OIDC provider instead of implementing LinkedIn authorization manually.
A deployment needs custom provider behavior beyond the defaults.
LinkedIn is configured by importing the built-in provider and placing it in the Auth.js providers array. In a Next.js setup, the page shows the provider directly as LinkedIn when environment variables supply its credentials.
Follow-up: What callback URL should be registered? Use https://example.com/api/auth/callback/linkedin for the standard Next.js API route setup.
The documented environment variables are AUTH_LINKEDIN_ID and AUTH_LINKEDIN_SECRET. They provide the LinkedIn application credentials without putting them directly in the configuration code.
Follow-up: What changes if credentials are passed explicitly? The core provider factory accepts an options object containing clientId and clientSecret.
The provider has built-in defaults and Auth.js assumes it follows OpenID Connect. If the defaults do not fit an application, the provider configuration can be overridden using the built-in provider customization mechanism.
Follow-up: What does the core factory return? Its options parameter is OIDCUserConfig<P>, and it returns OIDCConfig<P>.
LinkedInProfileOIDCUserConfigOIDCConfigcustomizing a built-in OAuth provider