makrdev
makrdev4mo ago

What’s the best way to connect Convex DB to external services?

Hey everyone, new fan here! 🍻 I’m trying to dive into Convex and figure out how to integrate it with our current workflow. Using Convex on the client side is pretty straightforward, but I’m struggling to understand how to connect to the database from external services, like a task engine running on Cloudflare Workers. Do we need to expose our queries or mutations using httpAction and build another layer for type safety? Thanks in advance for your help! 🤜
10 Replies
Convex Bot
Convex Bot4mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee4mo ago
what language is running on the Cloudflare Workers? Convex has several clients, maybe you want the python one https://docs.convex.dev/client/python you could use an httpAction instead, but calling the queries and mutations directly sounds simpler
Python | Convex Developer Hub
See the Python Quickstart and the
makrdev
makrdevOP4mo ago
It’s JavaScript similar to Convex runtime. I’m looking for something like an admin client that I can run on the server(edge) with type safety.
jamwt
jamwt4mo ago
Node.js | Convex Developer Hub
Convex supports point-in-time queries (see
jamwt
jamwt4mo ago
that's for streaming with a websocket. if you're purely doing one-shot request/response, you can use ConvexHTTPClient it uses only browser apis, so it works in any edge environment. it doesn't actually rely on any node.js stuff
makrdev
makrdevOP4mo ago
Thank you guys 🤜
ballingt
ballingt4mo ago
Any feedback about how we can make this more clear would be welcome, maybe we should add a section in the sidebar for "edge runtimes." And let us know if you hit any issues!
No description
ballingt
ballingt4mo ago
(I highlighted these bits not to point out there were there but to think about how they could be clearer) My first thought is "let's just list all of them," there can't be that many. Cloudflare workers, AWS Lambdas (which are Node.js), Node.js, Bun, Deno, and maybe that's most of them?
makrdev
makrdevOP4mo ago
Hey Tom, I don’t think this is just a runtime clarification. I’ve been going through the documentation a lot lately (as well as other resources like Stack and the Youtube channel), and a few areas still seem a bit unclear to me: Server-to-Server Communication Convex works great in browser (client) environments, and the documentation is mainly focused on that. However, many applications involve microservices and require server-to-server communication. Since we’re using Convex as our single source of truth (for database and types, etc.), we should be able to communicate between servers in a type-safe way. When I came across the http-client, I thought, “Great, I can use this in an edge runtime.” But when I saw that it needed to be imported from convex/browser, I got a bit confused and started wondering if this might be an anti-pattern. What I’m suggesting is that the documentation and package could use more clarity and abstraction around this use case. Schema Migrations There’s not a lot of information about schema migrations in the documentation. From what I gathered from a blog post, Convex seems to handle this in a specific way. Schema migrations are a pain point for most developers, and it’s something we need to understand clearly before starting. Local Development This is another blurry area. Convex provides a dev environment for each developer on the team, and it automatically pushes local changes to this environment. That’s a great experience! But I had to watch videos and explore other resources to fully understand it. I’m still unclear on how we push changes to the production environment, how teams can collaborate on a project, and what workflows we should follow. Integrations I was happy to see that I can use Hono with Convex. Integrations like this create a sense of familiarity and help avoid the feeling of being locked into a closed environment. Also, creating content around keywords like Hono, Cloudflare Workers, Zod, etc., could attract more users through SEO and community engagement.
ballingt
ballingt4mo ago
Great feedback, thanks! The convex/browser entry point is particular is one I'd like to fix — could call it convex/client. Could you say more about
clarity and abstraction around this use case
re what abstractions you'd like?

Did you find this page helpful?