Next.js Discord

Discord Forum

Bcrypt alternative

Unanswered
Allegheny mound ant posted this in #help-forum
Open in Discord
Allegheny mound antOP
As bcrypt is not available on Edge runtime, how do I need to encrypt passwords?

11 Replies

European sprat
alternatively: don't use edge runtime where you use bcrypt
unless it's middleware then you can't change it
@European sprat unless it's middleware then you can't change it
Allegheny mound antOP
But it’s the registration API endpoint?
European sprat
i guess you should share code so someone may be able to assist
Allegheny mound antOP
Not behind my desk but there’s also nothing special to share.

Just an API route handler which creates a new user using Drizzle ORM, which talks to my PlanetScale database over HTTP(S).
I wanted to encrypt passwords using bcrypt, until I figured out it isn’t working with the Edge runtime
European sprat
you aren't forced to use edge right? if you need to use edge then maybe there's some other package that runs in edge runtime
Allegheny mound antOP
Right, but I want them to be on Edge because it’s fast and scalable.

Will have to look into it tomorrow, can’t believe I’m the only one stuck with this issue.
European sprat
I haven't used it but bcrypt.js may be what you need
Asian black bear
If the authentication route is only run once per session and involves using a database and other "slow" stuff to return something like a JWT, is it really that harmful to use the node runtime for that one route?
It doesn't force your entire project not to use edge