question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make crypto usage configurable (enabling NextAuth.js to be used in Cloudlfare Workers, Vercel Edge, Deno Deploy, etc.)

See original GitHub issue

Description 📓

@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:closed
  • Created a year ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
balazsorban44commented, Aug 14, 2022

🔥

1reaction
balazsorban44commented, Aug 12, 2022

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 a Response.

Trying to deploy any NextAuth.js app to Vercel Edge would do the trick

This is the eventual goal. AFAIK we don’t use crypto directly anywhere, it’s likely node-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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Crypto in Edge Functions and Middleware - Vercel
Learn to utilize the crypto Web APIs at the edge. Framework Next.js. Use Case Edge Functions, Documentation. CSS Tailwind. Publisher △ Vercel. Deploy....
Read more >
Setting up NextAuth.js application and deploying it via Vercel
Setting up NextAuth. Start off by creating a Next.js application. Run the following command in the terminal npx create-next-app@latest.
Read more >
FSJam Podcast - Transistor.fm
In this episode we discuss the difficulties of running jobs on serverless, use cases for Netlify's Scheduled Functions, the future of Blitz.js, ...
Read more >
Cloudflare Teams Up With Open Source Community to Create ...
js seamlessly and without the need to rewrite an application. “Cloudflare Workers has helped to define the standard for edge computing. Since ...
Read more >
Syntax - Tasty Web Development Treats - Podcast Addict
By Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers ... could use web workers for Party Town Deno 19:52 Sponsor:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found