Mhmod-Hsn

payload social auth

by Mhmod-Hsn
Authentication & SSO
v3
^3.82.1
MIT

Overview

Summary generated from the README

Adds social OAuth sign-in to Payload CMS 3 and injects provider buttons onto the login screen. It is configured through a plugin function in the Payload config with client credentials for each provider. New users can be created automatically, and several providers can be linked to one account by matching email.

Features

  • Login buttons for GitHub, Google, Facebook, Twitter and LinkedIn on the admin sign-in page
  • Automatic user creation on first successful social login
  • Links multiple providers to one user account when the email matches
  • Session cookie with configurable name, expiration and security flags
  • onAuthSuccess and onAuthFailure callbacks for logging or onboarding
  • Optional custom callback URL and scope for each provider

Use cases

  • Let editors sign in to the Payload admin with their Google or GitHub accounts
  • Onboard new users automatically without manual account creation
  • Run custom logging or analytics when a social login succeeds or fails

From the author

Social Auth plugin for Payload CMS

Installation

npm i payload-social-auth

3

Stars

0

Forks

0

Open Issues

7 months ago

Last Updated

9

Weekly Downloads

v1.0.0

npm Version

127.5 KB

Unpacked Size

1

Dependencies

GitHub stars

3+2 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20263
Dec 4, 20263
Dec 3, 20263
Dec 2, 20263
Dec 1, 20263
Nov 30, 20263
Nov 29, 20263
Nov 28, 20263
Nov 27, 20263
Nov 26, 20263
Nov 25, 20263
Nov 24, 20263
Nov 23, 20263
Nov 22, 20263
Nov 21, 20263
Nov 20, 20263
Nov 19, 20263
Nov 18, 20263
Nov 17, 20263
Nov 16, 20263
Nov 15, 20263
Nov 14, 20263
Nov 13, 20263
Nov 12, 20263
Nov 11, 20263
Nov 10, 20263
Nov 9, 20263
Nov 8, 20263
Nov 7, 20263
Nov 6, 20263
Nov 5, 20263
Nov 4, 20263
Nov 3, 20263
Nov 2, 20263
Nov 1, 20263
Oct 31, 20263
Oct 30, 20263
Oct 29, 20263
Oct 28, 20263
Oct 27, 20263
Oct 26, 20263
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20263
Oct 21, 20263
Oct 20, 20263
Oct 19, 20263
Oct 18, 20263
Oct 17, 20263
Oct 16, 20263
Oct 15, 20262
Oct 14, 20262
Oct 13, 20262
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261
npm weekly downloads

5−2 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20265
Dec 4, 20266
Dec 3, 20263
Dec 2, 20263
Dec 1, 20266
Nov 30, 20267
Nov 29, 20266
Nov 28, 20266
Nov 27, 20265
Nov 26, 20265
Nov 25, 20265
Nov 24, 20262
Nov 23, 20262
Nov 22, 20263
Nov 21, 20263
Nov 20, 20262
Nov 19, 20264
Nov 18, 20264
Nov 17, 20264
Nov 16, 20263
Nov 15, 20262
Nov 14, 20263
Nov 13, 20263
Nov 12, 20262
Nov 11, 20262
Nov 10, 20263
Nov 9, 20263
Nov 8, 20264
Nov 7, 20263
Nov 6, 20264
Nov 5, 20263
Nov 4, 20263
Nov 3, 20262
Nov 2, 20263
Nov 1, 20262
Oct 31, 20262
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20260
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20263
Oct 21, 20265
Oct 20, 20265
Oct 19, 20265
Oct 18, 20264
Oct 17, 20264
Oct 16, 20264
Oct 15, 20263
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20262
Oct 10, 20262
Oct 9, 20262
Oct 8, 20261
Oct 7, 20261
Oct 6, 20262
Oct 5, 20262
Oct 4, 20261
Oct 3, 20262
Oct 2, 20264
Oct 1, 20264
Sep 30, 20264
Sep 29, 20263
Sep 28, 20263
Sep 27, 20263
Sep 26, 20265
Sep 25, 20264
Sep 24, 20264
Sep 23, 20264
Sep 22, 20265
Sep 21, 20265
Sep 20, 20266
Sep 19, 20263
Sep 18, 20262
Sep 17, 20263
Sep 16, 20264
Sep 15, 20263
Sep 14, 20265
Sep 13, 20265
Sep 12, 20268
Sep 11, 20268
Sep 10, 20267
Sep 9, 20267
Sep 8, 20268
Sep 7, 20268
Sep 6, 20267

Each point is npm's rolling 7-day download count.

Health Score

44/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1230314990-root.svg)](https://payloaddirectory.dev/plugins/1230314990-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1230314990-root"><img src="https://payloaddirectory.dev/badge/1230314990-root.svg" alt="Payload Directory"></a>
Updated May 6, 2026Created May 5, 2026Published May 6, 2026

README

Payload Social Auth Plugin

A modern, highly-polished, and fully-featured social authentication plugin for Payload CMS (v3) that enables seamless OAuth login with GitHub, Google, Facebook, Twitter, and LinkedIn.

npm version license pnpm


📸 Screenshots

1. Beautiful Admin Sign-In Page

Featuring highly-polished, modern, and cohesive social login buttons that blend beautifully into Payload's dark/light modes:

Payload Social Auth Sign-In Page

2. Multi-Provider Linked User Accounts

Enables users to link multiple social identity providers seamlessly to a single user account:

Payload Social Auth Linked Accounts


✨ Features

  • Zero Configuration Buttons: Automatically injects beautifully styled social login buttons (with pixel-perfect SVG icons) directly onto the Payload login screen.
  • Multiple Providers: Full OAuth support for Google, GitHub, Facebook, Twitter, and LinkedIn.
  • Auto-User Provisioning: Automatically provisions new Payload users upon successful social authentication.
  • Multi-Account Linking: Links multiple social identities (e.g., Google and GitHub) to the same user account if they share the same email address.
  • Secure Session Management: Native session-token cookie integration with customizable expiration, HttpOnly, Secure, and SameSite flags.
  • Type-Safe callbacks: Customizable onAuthSuccess and onAuthFailure hooks for logging, onboarding flows, or analytics.

🚀 Installation

Install the package via your preferred package manager:

pnpm add payload-social-auth
# or
npm install payload-social-auth
# or
yarn add payload-social-auth

🛠️ Usage

Simply import and add the plugin to your Payload configuration (payload.config.ts):

import { buildConfig } from 'payload';
import { socialAuthPlugin } from 'payload-social-auth';

export default buildConfig({
  // ... your existing config
  plugins: [
    socialAuthPlugin({
      providers: {
        github: {
          clientId: process.env.GITHUB_CLIENT_ID!,
          clientSecret: process.env.GITHUB_CLIENT_SECRET!,
        },
        google: {
          clientId: process.env.GOOGLE_CLIENT_ID!,
          clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
        },
        // Add other providers as needed
      },
      jwtSecret: process.env.PAYLOAD_SECRET, // optional, defaults to Payload's secret
      cookieName: 'payload-token', // optional
      autoCreateUser: true, // optional, defaults to true
      onAuthSuccess: async (user, provider) => {
        console.log(`User ${user.id} logged in via ${provider}`);
      },
      onAuthFailure: async (error, provider) => {
        console.error(`Auth failed via ${provider}:`, error);
      }
    }),
  ],
});

⚙️ Configuration Options

OptionTypeDefaultDescription
disabledbooleanfalseEnable/disable the plugin
providersobject{}Configuration object for social providers (github, google, facebook, twitter, linkedin)
providers.[provider].clientIdstringRequiredOAuth client application ID
providers.[provider].clientSecretstringRequiredOAuth client application secret
providers.[provider].callbackURLstringOptionalCustom callback URL
providers.[provider].scopestringOptionalCustom OAuth scope string
jwtSecretstringpayload.secretJWT secret used to sign session cookies
cookieNamestringpayload-tokenCustom authentication cookie name
autoCreateUserbooleantrueAutomatically create a new user if one does not exist
onAuthSuccessfunctionundefinedAsync callback triggered on successful login
onAuthFailurefunctionundefinedAsync callback triggered on failed login

🔑 Social Provider Setup

To configure OAuth credentials, create client applications in each corresponding developer portal:

🐙 GitHub Setup

  1. Visit GitHub Developer Settings.
  2. Register a new OAuth Application.
  3. Configure Authorization Callback URL to: https://your-domain.com/api/oauth/github.
  4. Copy your Client ID and generate a new Client Secret.

🔍 Google Setup

  1. Go to the Google Cloud Console.
  2. Create or select a project, then configure your OAuth Consent Screen.
  3. Under Credentials, create an OAuth 2.0 Client ID.
  4. Set Authorized redirect URIs to: https://your-domain.com/api/oauth/google.
  5. Save and copy your Client ID and Client Secret.

📘 Facebook Setup

  1. Visit Facebook Developers Portal.
  2. Create a new App and add the Facebook Login product.
  3. Navigate to Settings and configure Valid OAuth Redirect URIs as: https://your-domain.com/api/oauth/facebook.
  4. Retrieve your App ID and App Secret.

🐦 Twitter Setup

  1. Go to the Twitter Developer Portal.
  2. Create a Project and App with User Authentication settings enabled.
  3. Set your Callback URI / Redirect URL to: https://your-domain.com/api/oauth/twitter.
  4. Note down your API Key and API Secret.

💼 LinkedIn Setup

  1. Visit the LinkedIn Developer Portal.
  2. Create an App and associate it with a page.
  3. Under the Auth tab, add your Authorized Redirect URLs: https://your-domain.com/api/oauth/linkedin.
  4. Copy your Client ID and Client Secret.

🔒 License

Licensed under the MIT License.

Similar plugins