Open JakubKoralewski opened 3 years ago
Anyway we could support this?
How would it work?.
Store sessions on redis for fast server side session validation, but, choosing another database and adapter to work with the actual data.
An example could be postgres
+ prisma (adapter)
and storing sessions on redis
.
Hi! I don't develop features for this project anymore, but if you'd like to try this I am happy to help you along the way.
It's been a while since I wrote/read this code, but I think you'd need to write a custom adapter for next-auth which will know how to associate session data with user id's from e.g. Postgres; and know when to talk to Redis vs when to Postgres. I think it's more complicated with next-auth than it would be without tbh, since when implementing those functions like createUser
you'd need to talk to Postgres, but createSession
you'd want to put in Redis. You'd probably need to also store users in Redis to eliminate talking to Postgres when logging in, but then you have the problem of 2 copies of data, and issues with synchronization... Interesting problem.
What about using my custom backend that already has everything set up? Pretty much I will just be using next auth to store server side sessions on the client (cookies). Does that seems feasible?
Currently sessions are stored in Postgres despite having a Redis instance available.
https://github.com/JakubKoralewski/lets-watch-it-together/blob/5fdc81f6e62b1b0c85f18d5f0d054dd108281716/src/pages/api/auth/%5B...nextauth%5D.ts#L143
Related:
https://github.com/nextauthjs/next-auth/issues/544