Make crypto usage configurable (enabling NextAuth.js to be used in Cloudlfare Workers, Vercel Edge, Deno Deploy, etc.)
See original GitHub issueDescription 📓
@cyco130 and myself are trying to use NextAuth.js with Cloudflare Workers and Vercel Edge.
But NextAuth.js uses Node.js’s crypto API which isn’t available on these deployment platforms.
Are there plans to make the crypto tooling configurable? In order to enable the use of NextAuth.js with other crypto tools that support Cloudflare Workers / Vercel Edge. (E.g. jose
works with Cloudflare Workers.)
Also, I’m curious: I would guess that making NextAuth.js work with Vercel Edge is a high priority? Since most NextAuth.js users are Next.js users.
(I’ve seen https://github.com/nextauthjs/next-auth/issues/725 but it’s almost two years old and things have changed a lot since then, e.g. Balázs’s work and Vercel Edge.)
How to reproduce ☕️
Trying to deploy any NextAuth.js app to Vercel Edge would do the trick. But let me know if you want some kind of reproduction.
Contributing 🙌🏽
Yes, I am willing to help implement this feature in a PR. (Edit: probably not in the near future though.)
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:7 (2 by maintainers)
🔥
Thanks for your interest! For now, only
next-auth/middleware
is Edge-compatible, but we plan to make the whole core compatible.I am actively working on migrating away any Node.js-specific APIs from the core of NextAuth.js, and also making it so that you can pass it a standard
Request
and it will return aResponse
.This is the eventual goal. AFAIK we don’t use
crypto
directly anywhere, it’s likelynode-openid-client
that does so, which we are migrating away from in #4299 (rather making it opt-in for backward compatibility).This will also make it easier to turn the POC SvelteKit integration into an actual package. cc @wobsoriano
The remaining tasks are tracked here:
I don’t think it would make sense to have a specific API to make
crypto
configurable, as it will be transitively handled once the above changes are made.I’m closing this, for now, you can follow the PRs above, and give any suggestions there! 🙏
PS.: We will likely need help (docs/implementation) to recommend Database Adapters that play well with Edge, do let us know if you want to help with that.