Authjs Database strategy with Prisma
Unanswered
Eastern Phoebe posted this in #help-forum
Eastern PhoebeOP
Hi all π
can you setup authjs with prisma and database session? if so how can this be achived? i got a working setup with jwt strategy
can you setup authjs with prisma and database session? if so how can this be achived? i got a working setup with jwt strategy
11 Replies
@Eastern Phoebe Hi all π
can you setup authjs with prisma and database session? if so how can this be achived? i got a working setup with jwt strategy
Double-striped Thick-knee
as far as I know. database sessions doesn't work with credentials provider
@Double-striped Thick-knee as far as I know. database sessions doesn't work with credentials provider
Eastern PhoebeOP
Hi Sajid, I don't use credentials provider. I use Authjs with Prisma ORM and Magic Link authentication
@Eastern Phoebe Hi Sajid, I don't use credentials provider. I use Authjs with Prisma ORM and Magic Link authentication
Double-striped Thick-knee
it should work then
you can use the prismaAdapter
@Double-striped Thick-knee it should work then
Eastern PhoebeOP
do you have any guide/tutorial/docs? when i switched to database strategy my middleware stopped working. req.auth was null everytime
@Eastern Phoebe do you have any guide/tutorial/docs? when i switched to database strategy my middleware stopped working. req.auth was null everytime
Double-striped Thick-knee
authjs docs sucks but see if it works,
https://authjs.dev/getting-started/adapters/prisma
I also found this tutorial, tho it uses next-auth
https://github.com/wpcodevo/nextauth-nextjs13-prisma
https://authjs.dev/getting-started/adapters/prisma
I also found this tutorial, tho it uses next-auth
https://github.com/wpcodevo/nextauth-nextjs13-prisma
@Double-striped Thick-knee authjs docs sucks but see if it works,
https://authjs.dev/getting-started/adapters/prisma
I also found this tutorial, tho it uses next-auth
https://github.com/wpcodevo/nextauth-nextjs13-prisma
Eastern PhoebeOP
everything works when i change the strategy to database unless the middleware. req.auth is always null??? any idea
export default auth((req) => {
const { nextUrl } = req;
const isLoggedIn = !!req.auth;
console.log(req.auth) // null
...
}when i request /api/auth/session i get session information back
@Eastern Phoebe everything works when i change the strategy to database unless the middleware. req.auth is always null??? any idea
ts
export default auth((req) => {
const { nextUrl } = req;
const isLoggedIn = !!req.auth;
console.log(req.auth) // null
...
}
Double-striped Thick-knee
I'm out of ideas. have you checked their github repo?
@Double-striped Thick-knee I'm out of ideas. have you checked their github repo?
Eastern PhoebeOP
i did. but it didnt help :/
thx anyway