Auth solutions for Cloudflare Workers
I think I've decided I want to build a Nuxt app deployed with CF Workers, but I'm getting confused on auth. I'm pretty new to webdev in general so sorry if any of this is dumb:
BetterAuth got a lot of recommendations but it looks like it doesn't have good worker compatibility.
Auth.js advertises good worker compat but there's some drama about there not being official Nuxt integration (does this matter much?), and the community module doesn't seem to have worker compat because it relies on Nuxt Server?
These's a nuxt-auth-utils module with good worker compat but I feel like I'd be straying a bit too far from popular, well-supported standards at that point, which is somewhat important to me in case solutions like this just get randomly archived.
Clerk was also highly recommended but the costs seem way too high if the site gets really popular.
I see some people recommending things like supabase auth but I don't want to pay for and call out to other services if I can help it.
I just want something well-supported and easy to wire up in a Nuxt app in an edge runtime environment. I'm guessing Auth.js would be fine but the drama over the official nuxt module and the lack of worker compat from the community module has me confused on how easy it would be to use.
2 Replies
Hi @whorf. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
For authentication in a Nuxt app deployed on Cloudflare Workers, the most straightforward and officially documented solution is to use the nuxt-auth-utils module. This module is specifically designed for compatibility with edge runtimes like Cloudflare Workers and uses sealed cookies for session management, so you don't need a database just for sessions. The official Nuxt documentation provides a clear recipe for setting this up, including login API routes and client-side session management. It is actively maintained and recommended in the Nuxt docs for edge/serverless environments, including Cloudflare Workers. You can find a full example in the Nuxt Sessions and Authentication recipe and see that it is compatible with Workers deploymentsDocs: Sessions and Authentication.
Regarding Auth.js: The knowledge sources do not provide any official documentation or guidance for using Auth.js with Nuxt on Cloudflare Workers. The Nuxt community module for Auth.js appears to rely on Nuxt Server, which is not compatible with Workers, and there is no mention of official support for edge runtimes in the provided sources. Therefore, based on the available information, using Auth.js with Nuxt on Cloudflare Workers may not be straightforward or officially supported.
Other solutions like Clerk or Supabase Auth are not covered in the official Nuxt documentation for Cloudflare Workers, and concerns about cost or reliance on external services are valid, especially if you want to avoid third-party dependencies.
Summary:
- nuxt-auth-utils is the recommended, well-supported, and easy-to-integrate solution for authentication in Nuxt apps deployed to Cloudflare Workers, according to the official Nuxt documentation. - There is no official or documented support for Auth.js or the community Auth.js module for Nuxt on Cloudflare Workers in the provided sources. - Clerk and Supabase Auth are not covered in the official Nuxt docs for Workers. If you want a solution that is documented, maintained, and designed for edge compatibility, nuxt-auth-utils is your best bet for nowDocs: Sessions and Authentication. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
- nuxt-auth-utils is the recommended, well-supported, and easy-to-integrate solution for authentication in Nuxt apps deployed to Cloudflare Workers, according to the official Nuxt documentation. - There is no official or documented support for Auth.js or the community Auth.js module for Nuxt on Cloudflare Workers in the provided sources. - Clerk and Supabase Auth are not covered in the official Nuxt docs for Workers. If you want a solution that is documented, maintained, and designed for edge compatibility, nuxt-auth-utils is your best bet for nowDocs: Sessions and Authentication. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@426851559952089088> Kapa.ai is still learning and improving, please let me know how I did by reacting below.