How to implement auth with Nextjs on Vercel + D1 as db?
I’m building a Next.js app hosted on Vercel and using Cloudflare D1 as my database, accessible only through a Cloudflare Worker. I need to implement authentication but I’m unsure how to handle it with this setup. What’s the best way to achieve this, and which auth library would you recommend?
3 Replies
Hey @amanzad. I tried using better-auth with D1 and ran into a lot of problems as there isnt a dedicated adapter.
U should try auth.js because it provides adapters for D1. I havent tried it yet but it should work
https://authjs.dev/getting-started/adapters/d1
Auth.js | D1
Authentication for the Web
ah okok will look into it, appreciate the help!