npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

payload-social-auth

v1.0.0

Published

Social Auth plugin for Payload CMS

Readme

Payload Social Auth Plugin

A social authentication plugin for Payload CMS that enables login with GitHub, Google, Facebook, Twitter, and LinkedIn.

Installation

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

Usage

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.JWT_SECRET, // optional, defaults to Payload's secret
      cookieName: 'payload-social-auth-token', // optional
      autoCreateUser: true, // optional, defaults to true
      defaultRole: 'user', // optional, defaults to 'user'
      onAuthSuccess: async (user, provider) => {
        // Custom logic after successful authentication
        console.log(`User ${user.id} authenticated via ${provider}`);
      },
      onAuthFailure: async (error, provider) => {
        // Custom logic after failed authentication
        console.error(`Auth failed via ${provider}:`, error);
      }
    }),
  ],
});

Configuration Options

| Option | Type | Description | |--------|------|-------------| | disabled | boolean | Enable/disable the plugin | | providers | object | Configuration for social providers (github, google, facebook, twitter, linkedin) | | providers.[provider].clientId | string | OAuth client ID | | providers.[provider].clientSecret | string | OAuth client secret | | providers.[provider].callbackURL | string | Optional callback URL | | providers.[provider].scope | string | Optional OAuth scope | | jwtSecret | string | JWT secret for signing tokens (optional) | | cookieName | string | Cookie name for storing auth state (optional) | | autoCreateUser | boolean | Whether to automatically create users (optional, defaults to true) | | defaultRole | string | Default role for new users (optional, defaults to 'user') | | onAuthSuccess | function | Callback after successful authentication | | onAuthFailure | function | Callback after failed authentication |

Provider Setup

GitHub

  1. Go to https://github.com/settings/developers
  2. Create a new OAuth App
  3. Set callback URL to https://your-domain.com/api/auth/github/callback
  4. Copy Client ID and Client Secret

Google

  1. Go to https://console.cloud.google.com/apis/credentials
  2. Create OAuth 2.0 Client ID
  3. Set authorized redirect URI to https://your-domain.com/api/auth/google/callback
  4. Copy Client ID and Client Secret

Facebook

  1. Go to https://developers.facebook.com/apps/
  2. Create a new app
  3. Add Facebook Login product
  4. Set Valid OAuth Redirect URIs to https://your-domain.com/api/auth/facebook/callback
  5. Copy App ID and App Secret

Twitter

  1. Go to https://developer.twitter.com/
  2. Create a new project and app
  3. Set Callback URI to https://your-domain.com/api/auth/twitter/callback
  4. Copy API Key and API Secret Key

LinkedIn

  1. Go to https://www.linkedin.com/developers/
  2. Create a new app
  3. Set Redirect URL to https://your-domain.com/api/auth/linkedin/callback
  4. Copy Client ID and Client Secret

How It Works

  1. The plugin adds two collections:

    • social-auth-providers: Stores provider configurations
    • social-auth-tokens: Stores user's social auth tokens
  2. It adds API routes for OAuth callbacks:

    • /api/auth/github/callback
    • /api/auth/google/callback
    • /api/auth/facebook/callback
    • /api/auth/twitter/callback
    • /api/auth/linkedin/callback
  3. When a user authenticates via a social provider:

    • The plugin handles the OAuth flow
    • Creates or finds a user in the users collection
    • Stores tokens in the social-auth-tokens collection
    • Returns a JWT for authentication

License

MIT