Skip to content

Add Nuxt 4 compatibility #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

luc122c
Copy link

@luc122c luc122c commented Jul 17, 2025

Closes #63 by adding ^4.0.0 to the compatibility range for Nuxt.

I have not yet tested this, although I have been using this module with compatibilityVersion: 4 for some time without issue.

@Barbapapazes
Copy link
Owner

It should works without this but let's wait for the official Nuxt Module migration guide to know.

@luc122c
Copy link
Author

luc122c commented Jul 17, 2025

There is a similar issue with the semver check here: vuejs/pinia#3009 (comment)

@ceigey
Copy link

ceigey commented Jul 21, 2025

I had to:

  • manually remove the module from nuxt.config.ts
  • run npm remove nuxt-authorization
  • re-run npx nuxi module add nuxt-authorization

... to get that message to go away (but maybe I was just overthinking things and npx nuxi module add nuxt-authorization@latest would work).

This is with the latest update from @Barbapapazes which introduced the simpler >=3.0.0 semver check (e.g. not this PR), and Nuxt 4 stable (e.g. just 4.0.0 not 4.0.0-alpha).

Copy link

pkg-pr-new bot commented Jul 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/Barbapapazes/nuxt-authorization@64

commit: 8aba70b

@samuelspagl
Copy link

Hi @Barbapapazes ,
I hope it's fine to ask something here in this PR, since I think it is somewhat related.

I am trying to upgrade my project to Nuxt 4 also utilizing the new shared folder. But it seems due to the newly structured imports in Nuxt-4 the auto-import of the functions is working for the app and server directories, but not the shared one.

Is this something that also needs to be updated on module level?

Thanks a lot in advance!

@Barbapapazes
Copy link
Owner

Hi @Barbapapazes ,

I hope it's fine to ask something here in this PR, since I think it is somewhat related.

I am trying to upgrade my project to Nuxt 4 also utilizing the new shared folder. But it seems due to the newly structured imports in Nuxt-4 the auto-import of the functions is working for the app and server directories, but not the shared one.

Is this something that also needs to be updated on module level?

Thanks a lot in advance!

Hey,

Could you tell me more about your use case?

@samuelspagl
Copy link

Yeah of course. It's pretty much the use case that's already described in the README.md

Now the resolvers are set up, you can define your first ability. An ability is a function that takes at least the user, and returns a boolean to indicate if the user can perform the action. It can also take additional arguments.
I recommend to create a new file shared/utils/abilities.ts to create your abilities:

I utilize the same structure as written. With Nuxt-V3 everything works as expected since there is only one tsconfig reference. But with Nuxt-V4 they splitted it into tsconfig.app.json, tsconfig.node.json, tsconfig.server.json and tsconfig.shared.json. And the imports for the module are only included in the server and app configuration, not in the shared. Therefore the auto-import does not work in the shared directory like it did with Nuxt-V4.

Reverting the tsconfig.json back to a single tsconfig.json will solve this. But it's not as Nuxt-V4 intends it, if I understood it correctly 😅.

I hope that I could clear things up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nuxt 4 compatibility
4 participants