The useUser() method by Auth0 is designed to retrieve information about a logged-in user by calling the /api/auth/me endpoint. This triggers the handleAuth() function, which sets up Auth0 (creating a sessionCache instance, etc.) and calls profileHandler(req, res).
Within the profileHandler function, we find a call to sessionCache.isAuthenticated(req, res), which checks the sessionCache for any existing session entry (key: req object, value: Encrypted data containing user details, access_token, id_token, etc.).
Given that each API call, such as those from /api/auth/me, /api/auth/login, or similar endpoints, occurs within separate serverless function calls, it raises the question of whether profileHandler (/api/auth/me) will actually discover an entry in the sessionCache.
Although we do add an entry during login (in callbackHandler), the persistence of that cached value between distinct Serverless Function calls remains unclear.
The nextjs-auth0 documentation mentions:
By default, the session is stateless and stored in an encrypted cookie. However, you can opt for a stateful session by implementing a store with get, set, and destroy methods to store the session on the server.
In conclusion, it appears that the session handling mechanism is indeed stateless.