Customization
Social Login Config

NextAuth Social Login Setup Guide

In this guide, we'll walk you through the process of setting up social logins for GitHub, Google, Facebook, LinkedIn, and Apple using NextAuth (opens in a new tab) in your project.

GitHub

  1. Create a new GitHub OAuth App:

  2. Configure NextAuth for GitHub:

  • Add the GitHub credentials to your .env file:
  GITHUB_ID=your-client-id
  GITHUB_SECRET=your-client-secret
  • Integrate GitHubProvider in your NextAuth configuration:
  GithubProvider({
    clientId: process.env.GITHUB_ID as string,
    clientSecret: process.env.GITHUB_SECRET as string,
  })
ℹ️

NOTE: Remember to replace placeholder values such as your-client-id and your-client-secret with your actual credentials.

Google

  1. Create a new Google OAuth Project:

  2. Configure NextAuth for Google:

  • Add the Google credentials to your .env file:
  GOOGLE_ID=your-client-id
  GOOGLE_SECRET=your-client-secret
  • Integrate GoogleProvider in your NextAuth configuration:
GoogleProvider({
  clientId: process.env.GOOGLE_ID ?? '',
  clientSecret: process.env.GOOGLE_SECRET ?? '',
});
ℹ️

NOTE: Remember to replace placeholder values such as your-client-id and your-client-secret with your actual credentials.

Facebook

  1. Create a new Facebook App:

  2. Configure NextAuth for Facebook:

  • Add the Facebook credentials to your .env file:
  FACEBOOK_CLIENT_ID=your-client-id
  FACEBOOK_CLIENT_SECRET=your-client-secret
  • Integrate FacebookProvider in your NextAuth configuration:
  FacebookProvider({
    clientId: process.env.FACEBOOK_CLIENT_ID as string,
    clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string,
  })
ℹ️

NOTE: Remember to replace placeholder values such as your-client-id and your-client-secret with your actual credentials.

LinkedIn

  1. Create a new LinkedIn App:

  2. Configure NextAuth for LinkedIn:

  • Add the LinkedIn credentials to your .env file:
  LINKEDIN_CLIENT_ID=your-client-id
  LINKEDIN_CLIENT_SECRET=your-client-secret
  • Integrate LinkedInProvider in your NextAuth configuration:
  LinkedInProvider({
    clientId: process.env.LINKEDIN_CLIENT_ID as string,
    clientSecret: process.env.LINKEDIN_CLIENT_SECRET as string,
    authorization: {
      params: {
        scope: 'openid profile email',
      },
    },
  })
ℹ️

NOTE: Remember to replace placeholder values such as your-client-id and your-client-secret with your actual credentials.

Apple

  1. Create a new Apple Developer Account:

  2. Configure NextAuth for Apple:

  • Add the Apple credentials to your .env file:
  APPLE_ID=your-client-id
  APPLE_SECRET=your-client-secret
  • Integrate AppleProvider in your NextAuth configuration:
  AppleProvider({
    clientId: process.env.APPLE_ID as string,
    clientSecret: process.env.APPLE_SECRET as string,
  })

Now you've successfully set up social logins for GitHub, Google, Facebook, LinkedIn, and Apple in your NextAuth project. Test each login provider to ensure everything is working as expected.

ℹ️

NOTE: Remember to replace placeholder values such as your-client-id and your-client-secret with your actual credentials.