nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

Add support for Nuxt 4

Open mridang opened this issue 6 months ago • 5 comments

Describe the feature

This feature request is to add full support and compatibility for Nuxt 4.

With the official release of Nuxt 4, developers are eager to migrate their projects to leverage its performance gains, improved developer experience, and new features. nuxt-auth is a critical part of the ecosystem for many Nuxt applications, and ensuring its compatibility will allow the community to build modern, secure applications without being locked into an older version of the framework.

Use Case: Any developer wanting to start a new project with Nuxt 4 or upgrade an existing Nuxt 3 project that uses nuxt-auth.

Alternatives Considered: The only alternatives are to either (1) postpone upgrading to Nuxt 4, missing out on its benefits, or (2) migrate away from nuxt-auth to a different authentication solution. Both are undesirable for developers who rely on this module.

How would you implement this?

Update Dependencies: The package.json would need to be updated to list Nuxt 4 packages in peerDependencies and update relevant development dependencies like @nuxt/kit and nuxt.

Adapt to Nuxt 4 Changes: The codebase would need to be audited and updated to ensure compatibility with key changes in Nuxt 4, including:

Project Structure: Verify that module injections and file generation work with Nuxt 4's app/ directory structure.

Data Fetching: Review usages of useAsyncData and useFetch within the module to align with Nuxt 4's updated data-fetching logic.

TypeScript: Test against Nuxt 4's improved TypeScript support to resolve any newly surfaced type errors or inconsistencies.

Server/Nitro: Ensure the server-side endpoints and middleware provided by nuxt-auth are fully compatible with the version of Nitro that ships with Nuxt 4.

Comprehensive Testing: Create a test project using Nuxt 4 and run a full suite of tests covering all authentication providers (AuthJS, local, refresh) to catch any regressions or breaking changes introduced by the new version.

Additional information

  • [x] Would you be willing to help implement this feature?

Provider

  • [x] AuthJS
  • [ ] Local
  • [ ] Refresh
  • [ ] New Provider

mridang avatar Jul 28 '25 15:07 mridang

v1.0.0 Seems to work on my upgraded Nuxt 4 project with authjs and local provider.

holtolee avatar Jul 31 '25 09:07 holtolee

Upgrade package.json to allow nuxt 4

agracia-foticos avatar Aug 14 '25 10:08 agracia-foticos

@mridang add "nuxt": "^3.17.6 || ^4", to package.json

agracia-foticos avatar Sep 04 '25 10:09 agracia-foticos

@agracia-foticos I think nuxt 3 support should be dropped as all development efforts have moved to Nuxt 4. If you look at the PR, you will see that along with Nuxt 4 support, the PR also updates many deps. Most of these will not be compatible with Nuxt 3.

So I think if you're looking for Next 3 support, you're better off closing my PR and taking an different approach. Please let me know if you want me do any other changes. Thank you

mridang avatar Sep 09 '25 06:09 mridang

v1.0.0 Seems to work on my upgraded Nuxt 4 project with authjs and local provider.

The module isn't working on my side with sidebase/nuxt-auth 1.1.0 and Nuxt v4

 ERROR  [@sidebase/nuxt-auth] Recursion detected at /api/auth/session. Have you set the correct auth.baseURL?      

feeeedox avatar Nov 01 '25 15:11 feeeedox