pandronu
CCConvex Community
•Created by pandronu on 9/27/2024 in #support-community
Getting Convex Auth to work with NextJS middleware
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 (attached image).
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 and if someone even tested if this worked correctly.
I wanted to create an issue on GH, but first wanted to double check if I'm missing something obvious.14 replies