Skip to content

Releases: CrawlerCode/payload-authjs

v0.9.1

13 Oct 21:53

Choose a tag to compare

0.9.1 (2025-10-13)

🩹 Fixes

  • Move webauthn components to dedicated export (#48)

v0.9.0

06 Oct 20:07

Choose a tag to compare

0.9.0 (2025-10-06)

🚀 Features

  • Add support for Auth.js passkey provider (#45)
  • Receive the auth.js instance from the payload using getAuthjsInstance (8230215)

🩹 Fixes

  • Enforce stricter types (50aa494)
  • Check user strategy in refresh hook (#47)

🏡 Chore

  • Add bundle size badge to README (c8bdcd1)
  • deps: Update npm dependencies (dbd0141)
  • nx: Use payload-authjs as workspace package for dev project (22021c4)

MIGRATION GUIDE

This version introduces a new setup method for the Auth.js instance.

Creating the Auth.js instance

Now you can obtain the Auth.js instance directly from the payload instance by using the getAuthjsInstance function. You no longer need to use the withPayload function and create the NextAuth instance.

Before:

// auth.ts
export const { handlers, signIn, signOut, auth } = NextAuth(
  withPayload(authConfig, {
    payloadConfig,
  }),
);

After:

// auth.ts
const payload = await getPayload({ config: payloadConfig });
export const { handlers, signIn, signOut, auth } = getAuthjsInstance(payload);
Lazy initialization of the Auth.js instance

If your are using lazy initialization of the Auth.js instance, you must use withPayloadAuthjs to set up the instance manually:

// auth.ts
export const { handlers, signIn, signOut, auth } = NextAuth(async () =>
  withPayloadAuthjs({
    payload: await getPayload({ config: payloadConfig }),
    config: authConfig,
    collectionSlug: "users",
  }),
);

See #35 for more details.

Custom events

If you define custom events within withPayload, you must move them directly into the auth.js configuration (auth.config.ts):

// auth.ts
export const { handlers, signIn, signOut, auth } = NextAuth(
  withPayload(authConfig, {
    payloadConfig,
    events: {
      signIn: async ({ adapter, payload, user }) => {
        // ...
      },
    },
  }),
);
// auth.config.ts
import { EnrichedAuthConfig } from "payload-authjs";

export const authConfig: EnrichedAuthConfig = {
  // ...
  events: {
    signIn: async ({ adapter, payload, user }) => {
      // ...
    },
  },
};

Further details can be found in the events section.

v0.8.4

02 Sep 20:14

Choose a tag to compare

0.8.4 (2025-09-02)

🩹 Fixes

  • Destroy authjs session using payload logout hook instead of overriding logout endpoints (912da9a)
  • Remove custom array id field for verificationTokens (#41)
  • PayloadSessionProvider: Unset the local session then request failed (ada1fdf)
  • SignInButton: Mount authjs SessionProvider to the admin panel to provide custom base path (#44)

🏡 Chore

  • deps: Update npm dependencies (3885fc4)
  • dev: Improve session overview and sign in/out buttons (c2d6698)

📓 Examples

  • Use authjs signOut server action (#43)

v0.8.3

29 Jul 18:19

Choose a tag to compare

0.8.3 (2025-07-29)

🩹 Fixes

  • Remove duplicate custom array id fields (6f0ab0d)

🏡 Chore

  • Refactor repository and author fields in package.json for better structure (9b4d548)
  • deps: Update npm dependencies (5d1d6a3)

v0.8.2

11 May 13:33

Choose a tag to compare

0.8.2 (2025-05-11)

🩹 Fixes

  • getPayloadSession: Don't pass readonly headers object directly to fetch function (#33)

📖 Documentation

  • Add examples section to README (507385e)

🏡 Chore

  • Improve payload api types for /me and /refresh-token endpoints (9bf9289)
  • deps: Update npm dependencies (1f30898)

v0.8.1

14 Apr 21:30

Choose a tag to compare

0.8.1 (2025-04-14)

🩹 Fixes

  • Change the behavior of the SignIn button for login with provider (#24)
  • Remove email field duplication if enableLocalStrategy (#29)

🏡 Chore

  • dev: Allow login with username for local strategy (b8c24b5)
  • nx: Rename examples to example (a0d1ab9)

v0.8.0

06 Apr 20:56

Choose a tag to compare

0.8.0 (2025-04-06)

🚀 Features

  • Add custom account row label component (89ce1a7)
  • Add support for other auth strategies (2c94c40)
  • getPayloadSession: Cache getPayloadSession function (ff3b25b)

🩹 Fixes

  • Merge remaining properties for fields with subfield (cfa143d)
  • Execute afterLogout hooks at logout endpoint (#16)
  • Extend PayloadSession with collection and strategy (4ca2cdf)
  • Fix mergeFields function for tabs fields (bdb393c)
  • Refresh authjs session cookie at payload "refresh-token" endpoint (66e50fc)
  • Revalidate payload-session tag on logout and refresh (25d4b8d)
  • Move from tsc to swc to be compatible with turbopack (#18)
  • AuthjsAuthStrategy: Respect auth.depth option of users collection (c06262b)
  • PayloadSessionProvider: Abort fetch session on unmount (0a5e859)
  • getPayloadSession: Preferably extract strategy from user._strategy & improved types (4b66142)

🔥 Performance

  • PayloadAdapter: Only retrieve necessary fields (6beebd2)

📖 Documentation

  • Add missing import for example (e3caebc)
  • Improve setup section (4c54dfd)

🏡 Chore

  • deps: Update npm dependencies (d269d92)
  • deps: Update npm dependencies (d98f3aa)
  • deps: Update npm dependencies (7e6a164)
  • deps: Set minimal required payload version to 3.16.0 (because export of headersWithCors) (b76df1a)
  • dev: Improve edge compatibility and some other small changes (d5e5d9e)
  • dev: Add token rotation for keycloak provider & sync account expires date with session expires (27ee17b)
  • dev: Add mongoose adapter (b6c4e23)
  • nx: Add examples type to changelog (5e9b181)

📓 Examples

  • multiple-auth-collections: Add example for using multiple authentication collections (b0ff26a)
  • with-payload-local-strategy: Add example for using payload local strategy (baa762d)
  • basic: Enable middleware by default (7374439)

v0.7.1

09 Feb 22:30

Choose a tag to compare

0.7.1 (2025-02-09)

🩹 Fixes

  • Register me hook always to provider expires timestamp (#12)
  • PayloadSessionProvider: Fix broken PayloadSessionProvider (67df23d)

v0.7.0

09 Feb 20:30

Choose a tag to compare

0.7.0 (2025-02-09)

🚀 Features

  • Allow custom tabs field in users collection (#14)
  • Add getPayloadSession & usePayloadSession (146eebe)
  • AuthjsAuthStrategy: Log a warning if user not found in the database but has an valid authjs session (1999a20)
  • PayloadAdapter: Added payload logger and log debug messages (957f589)

🩹 Fixes

  • Override payload refresh operation & fix session expiration (#12)

📖 Documentation

  • Add "Getting the payload session" section & improved some other wordings (f911249)

🏡 Chore

  • Fix eslint & typescript errors (d9c5895)
  • dev: Change nextjs port to 5000 (0115f0e)
  • dev: Allow js files (for import map) (3b4b16b)
  • dev: Add greeting component to admin dashboard (becc12a)
  • dev: Added all different options to get the session & add tailwind (57637ab)
  • dev: Add currentAccount field (3f1711d)

DEPRECATION

getPayloadUser is now deprecated. You should use getPayloadSession instead:

- import { getPayloadUser } from "payload-authjs";
+ import { getPayloadSession } from "payload-authjs";

const ServerComponentExample = async () => {
- const payloadUser = await getPayloadUser();
+ const session = await getPayloadSession();

  return (
    <>
      <h3>Payload CMS User:</h3>
-     <pre>{JSON.stringify(payloadUser)}</pre>
+     <pre>{JSON.stringify(session?.user)}</pre>
    </>
  );
};

v0.6.1

05 Feb 22:53

Choose a tag to compare

0.6.1 (2025-02-05)

🩹 Fixes

  • Fix findField function for subfields (#13)

📖 Documentation

🏡 Chore

  • deps: Update npm dependencies (804f3f3)