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
11 Replies
@v
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
Look like you want to call a mutation
Convex React | Convex Developer Hub
Convex React is the client library enabling your React application to interact
i tried to do it but got this error
@v
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
issorry 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
@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
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.
Next.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server