This is `canary` version of documentation. It's still under construction and review.
ZANREAL logoNEMO
Packages

NextAuth (Auth.js)

NEMO middleware functions for NextAuth (Auth.js)

Installation

Integrate NextAuth with your project using the official guides:

Auth.js Quickstart or Next.js App Example.

Just skip the part of setting up the middleware and follow the steps below.

Replace middleware.ts code

We need to edit primary middleware/proxy file to use the new middleware function.

@/proxy.ts
import { auth as authMiddleware } from "@/auth";
import { type MiddlewareConfig, type GlobalMiddlewareConfig, createNEMO } from '@rescale/nemo';

const globalMiddlewares: GlobalMiddlewareConfig = {
  before: async (request, event) => {
    await authMiddleware((_request, _event) => {
      const { auth } = _request;
      event.storage.set("user", auth?.user);
    })(request, event);
  }
}

const middlewares: MiddlewareConfig = {
  '/': [
    async (request, event) => {
      console.log('There is NEMO', event.storage.get("user"));
    },
  ],
};

export const proxy = createNEMO(middlewares, globalMiddlewares);

export const config = {
  matcher: ['/((?!_next/|_static|_vercel|[\\w-]+\\.\\w+).*)'],
};
@/middleware.ts
import { auth as authMiddleware } from "@/auth";
import { type MiddlewareConfig, type GlobalMiddlewareConfig, createNEMO } from '@rescale/nemo';

const globalMiddlewares: GlobalMiddlewareConfig = {
  before: async (request, event) => {
    await authMiddleware((_request, _event) => {
      const { auth } = _request;
      event.storage.set("user", auth?.user);
    })(request, event);
  }
}

const middlewares: MiddlewareConfig = {
  '/': [
    async (request, event) => {
      console.log('There is NEMO', event.storage.get("user"));
    },
  ],
};

export const middleware = createNEMO(middlewares, globalMiddlewares);

export const config = {
  matcher: ['/((?!_next/|_static|_vercel|[\\w-]+\\.\\w+).*)'],
};

Just use the user key inside storage as you need! 🎉