auth-module
auth-module copied to clipboard
[Important] Auth Module State
Nuxt 3 support
Nuxt 3 comes with built-in utilities to support session and authentication. We are working on a new official module. Meanwhile, we recommend:
- nuxt-auth-utils for Nuxt 3 made by @Atinux
other solutions:
- Sidebase Nuxt Auth based on next-auth
- AuthJs Nuxt based on Auth.js
- Implement your own auth using Lucia or Nuxt Auth Template
Idea of auth module started back into 2017 as a way to standardize API authorization flow with nuxt applications using store state (almost same time we introduced modules concept to nuxt it was one of examples). By the time passing usage of module and varieties went way further of what it was initially designed to be.
Having a provider agnostic auth module is a really complicated problem:
- Every auth provider has specific requirements and setup even when following standards like Oauth2
- Non implicit authentication flows require a backend API to be also configured properly (like laravel or passport)
- There is still no standard way to have universal state for nuxt applications
- Isomorphic http requests require properly configured endpoints for server-side rendering and proxy
- With static generated websites, we need to partially hydrate on client-side
- Documentation area needs more attention for each provider
Simply saying there was no solution (with current design) to make every project happy
By each of last five major releases, we tried to adopt with new requirements and nuxt updates but still module is buggy because of complexities above and legacy code-base and almost impossible to accept new contributions without breaking changes -- one fix break another usage.
With v5 project and HUGE help of @JoaoPedroAS51 we started with a major typescript rewrite to improve architecture of module. Yet still there are framework requirements to complete v5 rewrite:
- Built-in support for API routes in Nuxt framework (WIP)
- Standard way to handle sessions (@nuxt/session WIP)
- Partially auth state hydration for SSGs
Considering current status, auth module is not a stable or well-documented solution but also it doesn't means project is forgotten. We are trying hard to fill in the gap for missing core components for v5.
Some alternative packages suggested to make your own auth solution:
Update: Status page added to docs https://auth.nuxtjs.org/status Update: Thanks for all DMs for helping <3 Any help on docs is more than welcome via PRs
Regards and thanks for your patience 💚
@pi0 Thanks for the update.
I have a product using this module for oauth in production right now. It works, though with minor issues - unfortunately none of which are on your list of v5 requirements. It seems that your suggestion is that I drop this module and hand-code my own solution? Since none of your alternative packages support oauth.
A few of us have offered to step up and help maintain. For example, there are quite a few PRs for simple README and documentation updates that haven't been commented on. Are you open to that, instead?
@bmulholland Glad to hear that. Actually current version is basically working but there is yet a big gap in documentation, DX and with small bugs as mentioned.
For example, there are quite a few PRs for simple README and documentation updates that haven't been commented on. Are you open to that, instead?
That's for sure! Please ping me on discord if interested to help for issue triage and maintenance :)
I saw one of your tweets (few days ago ?) saying that you had some hard time sometimes with OSS. I hope you feel better now... 😄
Thanks for this module. ❤️ I have to admit that it's my first time w/ the authentication thing. It was hard understanding all the various setups and how it works. After a few blog posts + github issues, I achieved to make 2 implementations:
- Auth0 basic flow of email/password
- JWT w/ a custom backend given by my teammates
And looking at it afterwards, the struggle was not that big, the configuration looks slick and it's working great. I do still have some real concerns about the whole httpOnly
+ secure
cookie thing and the why tho. I also get that people's use cases can be unique and complex.
Meanwhile, you did a great job here ! So yeah, the documentation is maybe not crystal clear and few things are missing here and there but I wanted to send a huge thank you for your time and work ! 🙏🏻 Hope this project will continue and that you will get better. 👍🏻
Where can I find the documentation for the v4?
Where can I find the documentation for the v4?
Same question.
And if someone is interested:
plugins/api.ts
import type { Auth } from '@nuxtjs/auth-next'
export default function ({ $auth }: { $auth: Auth }, inject: any) {
console.log({ $auth })
if (!$auth || !$auth.loggedIn) {
return
}
}
$auth undefined
nuxt.config.js
{
modules: [
'@nuxtjs/auth-next'
],
auth: {
plugins: [ '@/plugins/api' ]
}
}
$auth defined
nuxt.config.js
{
modules: [
'@nuxtjs/auth-next'
],
auth: {
plugins: [ '@/plugins/api.ts' ]
}
}
v4 docs are here: https://github.com/nuxt-community/auth-module/tree/master/docs
It would be very helpful to us if you could share why auth-next isn't working for you, though. We can't fix it if we don't know :)
v4 docs are here: https://github.com/nuxt-community/auth-module/tree/master/docs
It would be very helpful to us if you could share why auth-next isn't working for you, though. We can't fix it if we don't know :)
I'm doing some freelance jobs with nuxt-auth which already have the v4 implemented and I don't want to spend time to rewrite it to use the v5.
The old plugin docs were removed ? I'm trying to find them, but I didn't yet
Hi @AllanPinheiroDeLima! You can find the docs of auth v4 here
Hi. Does @nuxtjs/auth-next support nuxt 3 app?
@hardcommitoneself ive been using this plugin with nuxt-bridge with no problems. I have updated to use the new composition api and to eventually migrate to nuxt3. If you have an already built application, I would suggest going on bridge first. Otherwise, I think it will work just fine, if you already how the module
Thanks, @AllanPinheiroDeLima. The following is my problem when I run build.
Please check out and let me know what a problem.
Many thansk!
@hardcommitoneself i can definitely say that I didn’t come across this error. I’ve had other errors, but most of them related to vite and nitro. Have ou tried to disable nitro in nuxt config to test it out?
Before I add '@nuxtjs/auth-next' in nuxt.config.ts, it is working well. But after added, the error occurs.
@hardcommitoneself there are other commenters on the issues saying that the plugin is not compatible with Nuxt3
- https://github.com/nuxt-community/auth-module/issues/1719#issuecomment-1089928369
I can say, definetely that with nuxt bridge it is working fine, because I'm using it right now. But to make this plugin ( and NuxtI18nModule ) work, I had to disable Nitro and Vite. So if you're not willing to test disabling them, there is a good chance that they will not work. Well, to be completely honest, there is a chance that they will not work either way, since Nuxt3 changed so many things alongside Vue3. If it does not work, you'll have to decide which is better: leaving this module behind and doing authentication yourself, looking for another auth plugin or downgrading your project to Vue2/Nuxt2 or Vue2/Nuxt-Bridge
Hi @AllanPinheiroDeLima. Actually, you are right. In order to properly support Nuxt 3 stack (and Nuxt 2 with all Bridge features), auth needs a major rewrite which will be introduced as a (new) official module. We are working on it piece by piece. In the meantime, you might implement simple auth flows with Composition API and useState
for Nuxt 3 :)
@pi0 hi, thanks for your work. When to expect a module for nuxt 3?
Roadmap is here: https://v3.nuxtjs.org/community/roadmap/#%EF%B8%8F-roadmap
Hi guys, the roadmap says the release of a version compatible with Nuxt3 is scheduled for 2022. Can you give me a rough idea of when you expect a release to be available (more or less)? Thanks 😃
Yes: 2022.
I meant more like september or december ;-)
Not to be snarky, but the point of the roadmap is to announce dates to the currently-known level of confidence. Having side conversations about dates to different levels of detail undermines the work put into maintaining the roadmap page. And, as with all roadmaps, dates and priorities are subject to change. The most current information is reflected on the roadmap, and any updates will be published there.
Good thing it was planned in 2022
Is there an updated estimation on when a nuxt3 compatible version might be available?
Any updates? 2023Q1 is coming to an end soon, and there's still nothing
Hi, Is there any way to implement Steam auth with Superbase in Nuxt?
If anyone is looking at this thread and wondering what to use for Nuxt 3 auth :
- Sidebase Nuxt Auth based on next-auth
- AuthJs Nuxt based on Auth.js
Implement your own auth using something like Lucia
Any updates?
So, what is happening with the official Auth Module?
@Vinccool96 still in the works if I'm not mistaken. 😊