Third party packages in Convex function
Hi, Can I use npm to install and use third party libraries in
convex
directory? I have tried but it seems not working.5 Replies
Yes, but not all libraries are compatible with queries and mutations — some must be used only in actions.
@ming what are you seeing?
I see, I was trying to add
axios
, it shows me this
Yeah it looks like axios is not compatible with queries and mutations, but should be compatible with actions.
FormData
specifically seems like something we should just support with queries and mutations, but other parts of axios (namely making HTTP requests) will only be compatible with actions -- Convex wants queries and mutations to be deterministic, which means they can't make external requests.@ming let us know if we can help, see https://docs.convex.dev/using/actions#defining-actions for more. Something that makes HTTP requests like Axios should be used in an action.
Actions | Convex Developer Hub
Example:
Thanks