Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Const

LinkedIn

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.

How it works

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.

Syntax

LinkedIn(options?: OIDCUserConfig<P>)

Parameters

NameTypeDescription
optionsOIDCUserConfig<P>Provider options including LinkedIn client credentials when configuring the core provider factory explicitly.

Returns

OIDCConfig<P>

Key points

  • Auth.js provides LinkedIn as a built-in provider rather than requiring a custom OAuth implementation.
  • For a standard Next.js deployment, register the LinkedIn callback at the documented API callback path.
  • The provider expects the LinkedIn client ID and secret through these two environment variables.
  • Auth.js supplies default LinkedIn configuration, so basic setup does not require manually specifying every protocol option.
  • Provider defaults can be replaced when an application needs nonstandard or customized behavior.

Common mistakes

  • The provider is treated as OIDC by default, so custom configuration should account for that behavior.
  • The provider page does not document an Express setup in its callback URL section.

Example: Configure LinkedIn with NextAuth

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.

When to use it

Next.js social login

Users sign in to a Next.js application with their LinkedIn accounts.

Built-in OIDC integration

An application needs a preconfigured OIDC provider instead of implementing LinkedIn authorization manually.

Customized provider configuration

A deployment needs custom provider behavior beyond the defaults.

Interview questions

QHow do you add LinkedIn authentication to a Next.js Auth.js configuration?

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.

QWhich environment variables does the LinkedIn provider use?

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.

QWhat protocol assumptions and customization behavior apply to LinkedIn?

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>.

  • LinkedInProfile
  • OIDCUserConfig
  • OIDCConfig
  • customizing a built-in OAuth provider

Source: LinkedIn Provider. Checked 2026-10-15.