Skip to content

createContext is not a function for NextJS middleware #87

Open
@iKonrad

Description

@iKonrad

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"
  },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions