WilsonLe

payload oauth2

by WilsonLe
Authentication & SSO
v3
^3
MIT

Overview

Summary generated from the README

Adds OAuth2 login to Payload CMS v3 through an authorize endpoint on an auth collection, which redirects users to the provider. It works with generic OAuth2 providers and has been tested with Google and Zitadel, with an Apple example config. The plugin has no runtime dependencies and is configurable.

Features

  • Works with generic OAuth2 providers
  • Tested with Google and Zitadel, with an Apple example config
  • Authorize endpoint on the auth collection that redirects to the provider
  • Zero dependencies
  • Ignores Next.js RSC navigation probes on the authorize endpoint

Use cases

  • Add Google sign-in to the Payload admin panel or an app's user collection
  • Connect Payload to a self-hosted identity provider such as Zitadel for single sign-on

From the author

OAuth2 plugin for Payload CMS

Installation

npm i payload-oauth2

198

Stars

21

Forks

8

Open Issues

5 months ago

Last Updated

0

Weekly Downloads

v1.0.21

npm Version

72.9 KB

Unpacked Size

0

Dependencies

GitHub stars

Trends appear after 7 days of data. Daily snapshots have not started yet.

npm weekly downloads

Trends appear after 7 days of data. Daily snapshots have not started yet.

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

Health Score

57/100Good

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/793272573-root.svg)](https://payloaddirectory.dev/plugins/793272573-root)
HTML
<a href="https://payloaddirectory.dev/plugins/793272573-root"><img src="https://payloaddirectory.dev/badge/793272573-root.svg" alt="Payload Directory"></a>
Updated May 12, 2026Created Apr 28, 2024Published May 12, 2026

README

Payload OAuth2 Plugin

Software License Issues NPM

Features

  • ✅ Compatible with Payload v3
  • 🔐 Configures OAuth2 with any providers
  • ✨ Zero dependencies
  • ⚙ Highly customizable

Integrations

Technically this plugin should work with all generic OAuth2 providers. Here are the list of providers that have been tested:

ProviderStatusExample
GoogleTest Google OAuthConfig
ZitadelTest Zitadel OAuthConfig
AppleTest not implementedConfig

Installation

npm install payload-oauth2
yarn install payload-oauth2
pnpm install payload-oauth2

If you are feeling adventurous and want to manage the plugin yourself, you can copy the src directory into your payload projects.

Starting the OAuth flow

Create a normal browser navigation to the Payload authorize endpoint from your login UI:

export function GoogleLoginButton() {
  return <a href="/api/users/oauth/google">Continue with Google</a>
}

In Next.js App Router apps, prefer not to start OAuth with next/link or router.push() for the authorize endpoint. The endpoint returns a redirect to the OAuth provider, not a React Server Component payload. The plugin defensively ignores Next.js RSC navigation probes so client routing can fall back without the noisy Failed to fetch RSC payload ... Falling back to browser navigation log, but normal document navigation is still the most direct option.

Contributing

Contributions and feedback are very welcome.

To get it running:

  1. Clone the project.
  2. pnpm install
  3. pnpm dev

License

The MIT License (MIT). Please see License File for more information.

Credits

This package was inspired by Payload Plugin OAuth.

Similar plugins