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

createContext is not a function for NextJS middleware #87

Open
iKonrad opened this issue Sep 27, 2024 · 1 comment
Open

createContext is not a function for NextJS middleware #87

iKonrad opened this issue Sep 27, 2024 · 1 comment

Comments

@iKonrad
Copy link

iKonrad commented Sep 27, 2024

I want to integrate Convex auth with NextJS. I'm following the following docs:
https://labs.convex.dev/auth/authz/nextjs

It requires setting up a middleware using convexAuthNextjsMiddleware - but whenever I try to use it, I get the following error:
problempng

I digged a bit and it seems that the @convex-dev/auth/nextjs/server/index.js (which is server-only file) is importing nextjs/client.js which is client-only and imports React hooks, which most likely is triggering the error.

I wonder how is that supposed to work? Did I miss something? I don't understand why the middleware was bundled together with context provider in a single file.

From my perspective, obvious solution would be to decouple context provider from middleware, but maybe there was a reason for this?

My deps:

"dependencies": {
    "@auth/core": "^0.35.2",
    "@convex-dev/auth": "^0.0.71",
    "convex": "^1.16.0-alpha.2",
    "next": "15.0.0-rc.0",
    "react": "19.0.0-rc-fb9a90fa48-20240614",
    "react-dom": "19.0.0-rc-fb9a90fa48-20240614"
  },
@iKonrad iKonrad changed the title createContext is not a function for NextJS 15 middleware createContext is not a function for NextJS middleware Sep 27, 2024
@sshader
Copy link
Contributor

sshader commented Oct 8, 2024

We're currently prioritizing support for the stable versions of Next + React (as opposed to working with release candidates). Until we prioritize support with the newer versions, Convex Auth will work best with the stable versions of react + next.

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

No branches or pull requests

2 participants