rkstlohchab
rkstlohchab7mo ago

convex with next server actions data fetching problem

i know i need to pass ctx in the frontend component but what exactly is ctx and how to pass it so that my server actions add data to the convex database
No description
11 Replies
rkstlohchab
rkstlohchabOP7mo ago
@v
v
v7mo ago
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
v
v7mo ago
Look like you want to call a mutation
v
v7mo ago
Convex React | Convex Developer Hub
Convex React is the client library enabling your React application to interact
rkstlohchab
rkstlohchabOP7mo ago
i tried to do it but got this error
No description
rkstlohchab
rkstlohchabOP7mo ago
@v
jamwt
jamwt7mo ago
taht doesn't appear to be a convex mutation. a convex mutation would be something like api.foo.bar where you're importing api from convex/_generated/server I'm not sure what @/lib/actions/actions is
v
v7mo ago
sorry mate i fell asleep oh wait yeah youre not importing that from convex i totally see whats going on you just put the mutation in the wrong location should go somewhere in your convex folder then you should run it with api.xxx and with useMutation inside Footer
rkstlohchab
rkstlohchabOP7mo ago
@jamwt @v thanks for the help I knew that i had to put the code in convex folder i was just curious if it will work with actions or is there any method
Nerdkidchiki
Nerdkidchiki7mo ago
Hi there...not really sure about this but i believe its possible to run it in an action with the "fetchMutation" function from convex/nextjs. you simply call it like a regular fetch call , pass it the api reference and optionally the token if it requires authorization.
Nerdkidchiki
Nerdkidchiki7mo ago
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server

Did you find this page helpful?