Skip to content
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

v5 Beta does not work with Next 15 RC (React 19 RC) - Middleware issue #11006

Closed
Aralf opened this issue May 24, 2024 · 3 comments
Closed

v5 Beta does not work with Next 15 RC (React 19 RC) - Middleware issue #11006

Aralf opened this issue May 24, 2024 · 3 comments
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@Aralf
Copy link

Aralf commented May 24, 2024

Environment

 System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 79.98 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 9.0.2 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.112
    Safari: 17.4.1
  npmPackages:
    next: 15.0.0-rc.0 => 15.0.0-rc.0 
    next-auth: 5.0.0-beta.18 => 5.0.0-beta.18 
    react: 19.0.0-rc-935180c7e0-20240524 => 19.0.0-rc-935180c7e0-20240524 

Reproduction URL

https://github.com/Aralf/next-intl-react-19-compiler/tree/authjs-v5

Describe the issue

The issue is related to this change vercel/next.js#65424 where in case we import something from react it will only import server related api and giving error for client apis.

I had a reproduction repository that uses next-intl and next-auth v4 as I had initially raised this issue with next-intl amannn/next-intl#1075
The root cause was found amannn/next-intl#1075 (comment) and after applying the suggested change everything got resolved.

But the issue still persisted in another project where I use v5 instead. So I made the a new branch (the one I provide as reproduction) where I have updated to v5 and sure enough a face the same issue.

When import the universal auth into middlware.ts it throws the following error

Screenshot 2024-05-25 at 01 09 00

I don't know if it is because auth itself of because the use of next-auth that returns auth along with the handlers, signIn, signOut, etc. and everything is exported from the same file. As the issue on next-intl was because of importing the file where their navigation solution (that used next/link internally ) was also exported, I assume something similar is happening here.

How to reproduce

Make sure you are on the branch authjs-v5 and run pnpm install & pnpm dev. Application will crash from the start.
You can then try with main where next-auth v4 is used and see that the application runs fine.

Expected behavior

It should work with Next 15 & React 19

@Aralf Aralf added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels May 24, 2024
@Gawdfrey
Copy link
Contributor

I had the same issue with next-intl and now next-auth, but it seems the latest canary release has a fix for both of these issues, see the fix. It works fine for me at least now.

Release

@Aralf
Copy link
Author

Aralf commented May 25, 2024

I had the same issue with next-intl and now next-auth, but it seems the latest canary release has a fix for both of these issues, see the fix. It works fine for me at least now.

Release

You are absolutely right, changing to latest canary where that fix is included resolves all the issues. Thanks @Gawdfrey

@ThangHuuVu
Copy link
Member

Closed as this isn't an issue with next-auth, thanks @Gawdfrey for pointing it out.

I had the same issue with next-intl and now next-auth, but it seems the latest canary release has a fix for both of these issues, see the fix. It works fine for me at least now.

Release

@ThangHuuVu ThangHuuVu closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

3 participants