Sara
Saraā€¢5mo ago

Problem with building @convex-dev/auth@0.0.50 in deployment

I have used the react import and it worked perfectly in development but not in production with nextjs. I updated the package and imported the ConvexAuthNextjsProvider and was hit with this error, any idea how I can resolve it?
No description
No description
23 Replies
v
vā€¢5mo ago
did you ever figure this out
Sara
SaraOPā€¢5mo ago
Not yet!
v
vā€¢5mo ago
its a sad world šŸ„²
Nathaniel
Nathanielā€¢5mo ago
Wow, hehe, you're very smart person. :Pepe_5:
ballingt
ballingtā€¢5mo ago
Since this is a Next.js project can you try using the ConvexAuthNextjsClientProvider instead of ConvexAuthProvider? The one you're using doesn't work in server, the value of the context will be undefined. Another solution would be to ensure the Provider is run on the client by adding "use client" to the file where you define the component that renders this provider.
Sara
SaraOPā€¢5mo ago
I may not have made it clear, I apologise: this is my code after the upgrade:
'use client'
import { Children } from "@/types";
import { ConvexAuthNextjsProvider, } from "@convex-dev/auth/nextjs";
import { ConvexReactClient } from "convex/react";

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export const Provider = ({ children }: Children) => {
return <ConvexAuthNextjsProvider client={convex}>{children}</ConvexAuthNextjsProvider>;
};
'use client'
import { Children } from "@/types";
import { ConvexAuthNextjsProvider, } from "@convex-dev/auth/nextjs";
import { ConvexReactClient } from "convex/react";

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export const Provider = ({ children }: Children) => {
return <ConvexAuthNextjsProvider client={convex}>{children}</ConvexAuthNextjsProvider>;
};
in which I'm facing the issue, also, I couldn't find ConvexAuthNextjsClientProvider declaration, can you lead me to it please? Update: THE PROBLEM IS I FORGOT TO ADD JWKS TO MY ENVIROMENT VARIABLES
Sara
SaraOPā€¢5mo ago
I went with what Michel did here and revised the docs to see what I'm missing, and yep, its the jwks!!! https://github.com/get-convex/convex-auth/tree/main/test-nextjs
GitHub
convex-auth/test-nextjs at main Ā· get-convex/convex-auth
Library for built-in auth. Contribute to get-convex/convex-auth development by creating an account on GitHub.
Sara
SaraOPā€¢5mo ago
2 hours of mess around and find out
v
vā€¢5mo ago
šŸ˜‚šŸ˜‚šŸ˜‚
jamwt
jamwtā€¢5mo ago
glad to hear it's working now!
Sara
SaraOPā€¢5mo ago
Almost Some other issues are caused and I'm trying to figure that out soon (like the userId is null even though it's within the client context)
v
vā€¢5mo ago
I have some issues like that too I gave up šŸ‘
Sara
SaraOPā€¢5mo ago
I can't give up Potentially cause I'll face this issue in the future
v
vā€¢5mo ago
Never back down never what?
Michal Srb
Michal Srbā€¢5mo ago
@v can you file a separate thread? @Sara if you don't need server-side-authentication you can keep using the /react provider, it's a simpler setup. Otherwise you need to follow all the App Router with SSA setup steps. Lmk if anything isn't working.
Sara
SaraOPā€¢5mo ago
so, so far I switched back to client context and I don't need server-side-authentication, but would be great to have it and I would love it if you could provide another example with the /src directory, since its not working the exact same way as when its /app
Michal Srb
Michal Srbā€¢5mo ago
Why are you using /src with App Router btw?
v
vā€¢5mo ago
its actually wasn't even for my projects i was helping someone
Sara
SaraOPā€¢5mo ago
its a personal preference Since every other framework I use sets a /src directory and it has become more convenient and organised
Michal Srb
Michal Srbā€¢5mo ago
And what issues are you running into when using the /src directory and Convex Auth? I'd imagine it works identically except you need to put all files in src/, so middleware goes to src/, components to src/app/, convex files stay in convex/
Sara
SaraOPā€¢5mo ago
alright that's fair, you'd be correct, the user is being viewed when you pull middleware, and app and components into /src
Sara
SaraOPā€¢5mo ago
GitHub
convex-auth/test-nextjs at main Ā· get-convex/convex-auth
Library for built-in auth. Contribute to get-convex/convex-auth development by creating an account on GitHub.
Sara
SaraOPā€¢5mo ago
so the issue I'm having is with my personal project, will try to figure that out later thank you @Michal Srb