This is an external open-source GitHub repository imported into the WOCSOL Marketplace for discovery. The original repository owner is the primary creator.
A Payload CMS 3 plugin for Auth.js/NextAuth 5
A Payload CMS 3 plugin for Auth.js/NextAuth 5
# Payload CMS plugin for Auth.js/NextAuth A [Payload CMS 3](https://payloadcms.com) plugin for integrating [Auth.js 5 (beta)](https://authjs.dev). > ⚠ This plugin and Auth.js 5 is in beta and may have some bugs. Please report any issues you find. > [!CAUTION] > ⚠ [Auth.js is now part of Better Auth](https://github.com/nextauthjs/next-auth/discussions/13252): It is unknown whether Auth.js 5 will ever be released as a stable version. Please consider this before using this plugin. # ⚡ How it works This plugin - creates a `users` collection in Payload CMS. - use an custom [Database Adapter](https://authjs.dev/getting-started/database) for Auth.js to store the users in the Payload CMS database. - use a custom [Auth Strategy](https://payloadcms.com/docs/authentication/custom-strategies) for Payload CMS to retrieve the session from Auth.js. # ⚙️ Installation / Setup Install the plugin using any JavaScript package manager such as PNPM, NPM, or Yarn: ```bash pnpm i payload-authjs ``` ### 1. Setup Auth.js This plugin integrates Auth.js into Payload CMS by getting the user session from Auth.js. You need to setup Auth.js before you can use this plugin. #### 1.1. Create your Auth.js configuration Define your Auth.js configuration in a file (e.g. `auth.config.ts`): ```ts // auth.config.ts import type { NextAuthConfig } from "next-auth"; import github from "next-auth/providers/github"; export const authConfig: NextAuthConfig = { providers: [ github, // ⚠ But unlike what you would normally do in Auth.js, you need to create the Payload instance first and using the `getAuthjsInstance` function to retrieve the Auth.js instance. ```ts // auth.ts import payloadConfig from "@payload-config"; import { getPayload } from "payload"; import { getAuthjsInstance } from
Ask questions or discuss this product. New comments are reviewed before publishing.
Loading comments...