Skip to content

v0.9.0

Choose a tag to compare

@CrawlerCode CrawlerCode released this 06 Oct 20:07

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.