NeonN
Neon2y ago
144 replies
sacred-rose

How do I properly use the serverless driver for prisma?

accidentally deleted original post... tried to edit lmao my bad.

nextjs 14
nextauth v5
prisma 5.13
neon serverless driver
package.json details are below

getting a ws error:
[auth][cause]: Error: All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ws 
does not work in the browser. Browser clients must use the native WebSocket object


I originally used the JWT session strategy but wanted to try the database session to experiment but also because I thought it would fix this issue.

JWT session:
When I attempt to access my database from the JWT or session callback in nextauth I get the error. I was hoping I could try to get updated user data in the session without them having to login.

Database session:
I get the error on every page refresh, and on every sign in attempt. Also when I sign in it seems successful but keeps me on the sign in page and does not redirect. If I go to the home page I see there is some sort of session that is working as the user menu shows my name + email but it does not show the providers image for some reason. if I go to the settings page after this it will redirect me to back to the login page
Was this page helpful?