star ✨S
Convex Community3y ago
12 replies
star ✨

Could not find ConvexClient in Next.js

So I have something like this:

_app.tsx
<ClerkProvider publishableKey={env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}>
        <ConvexProviderWithClerk client={convex} useAuth={useAuth}>
<Component />
</ConvexProviderWithClerk>
</ClerkProvider>


parentComponent.tsx
const Layout = ({children}) => {
 const updateNode = useMutation(api.nodes.updateTextNode);

//---stuff---

return (
{children}
)
}


OtherComponent.tsx
const Other= ()=>{
return (
<Layout>
<Child />
</Layout>
)
}


Child.tsx
const Child= ()=>{
 const updateNode = useMutation(api.nodes.updateTextNode);

//rest of the component
}


I get
Error: Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it?
if I add the useMutation hook in the child
Was this page helpful?