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

@vladanilicjs/payload-auth-plugin

v0.6.0

Published

Authentication plugin for Payload CMS with flexible collection relationships

Readme

cover image

payload-auth-plugin (Enhanced Fork)

This is an enhanced fork of the original payload-auth-plugin with added support for flexible collection relationships.

What's Different in This Fork?

This fork adds one significant enhancement to the original plugin:

Flexible Collection Relationships: Instead of only being able to link OAuth accounts to the admin users collection, you can now configure the plugin to link accounts to any collection in your Payload CMS.

This enables scenarios such as:

  • Customer authentication instead of just admin authentication
  • Different authentication flows for different user types
  • More flexible application architecture

Installation

npm install @vladanilic/payload-auth-plugin
# or
yarn add @vladanilic/payload-auth-plugin
# or
pnpm add @vladanilic/payload-auth-plugin

Usage

For basic usage instructions, please refer to the original documentation.

Using Flexible Collection Relationships

To link OAuth accounts to a collection other than the default users collection:

import { buildConfig } from "payload/config"
import { adminAuthPlugin } from "@vladanilic/payload-auth-plugin"
import { GoogleAuthProvider } from "@vladanilic/payload-auth-plugin/providers"

export default buildConfig({
  serverURL: "http://localhost:3000",
  // Your collections definition
  collections: [
    // Other collections...
    {
      slug: "customers",
      fields: [
        {
          name: "email",
          type: "email",
          required: true,
          unique: true,
        },
        // Other fields...
      ],
    },
  ],
  plugins: [
    adminAuthPlugin({
      providers: [
        GoogleAuthProvider({
          client_id: process.env.GOOGLE_CLIENT_ID,
          client_secret: process.env.GOOGLE_CLIENT_SECRET,
        }),
      ],
      // Define a custom relation to the "customers" collection
      relationConfig: {
        fieldName: "customer", // Field name in accounts collection
        relationTo: "customers", // Target collection
        collectionField: "email", // Field to use for user matching
        hasMany: false,
        required: true,
        label: "Customer",
      },
      // Allow creating new customers automatically if they don't exist
      allowSignUp: true,
      // Custom redirect path after login
      successPath: "/admin/collections/customers",
    }),
  ],
  // Other Payload config...
})

Default Behavior

If you don't specify a relationConfig, the plugin works exactly like the original, linking accounts to the admin users collection.

Status of This Fork

This fork has been submitted as a pull request to the original repository. If accepted, I recommend you switch back to the original package once the changes are published there.

For all other documentation, please refer to the official documentation.

Compatibility / Troubleshooting after Payload upgrades

This package lists payload as a peer dependency (^3.0.0), which means it can be installed with newer Payload v3 versions in your app (e.g. 3.69.0). The payload version in this repo is only used for developing the plugin.

If auth “suddenly stops working” after upgrading Payload in your project:

  • Clear cookies: remove the ${cookiePrefix}-token cookie for your domain and re-login.
  • Version alignment: make sure all Payload packages in your app resolve to the same version (e.g. payload, @payloadcms/ui, DB adapters, storage plugins).
  • Isolate the plugin: temporarily disable adminAuthPlugin({ enabled: false, ... }). If core Payload login starts working again, the issue is in the plugin auth flow.
  • Cookies in HTTPS: if you run behind HTTPS, cookies may need Secure. The plugin sets Secure automatically when serverURL starts with https://.

If you still get stuck, check your browser network tab for the OAuth callback response and confirm it returns a Set-Cookie header for the token cookie.

License

This project is licensed under the MIT License - see the LICENSE file for details.