rkstlohchab
rkstlohchab4mo 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
rkstlohchabOP4mo ago
@v
v
v4mo ago
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
v
v4mo ago
Look like you want to call a mutation
v
v4mo ago
Convex React | Convex Developer Hub
Convex React is the client library enabling your React application to interact
rkstlohchab
rkstlohchabOP4mo ago
i tried to do it but got this error
No description
rkstlohchab
rkstlohchabOP4mo ago
@v
jamwt
jamwt4mo 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
v4mo 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
rkstlohchabOP4mo 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
Nerdkidchiki4mo 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
Nerdkidchiki4mo 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?