Skip to content

Connect

Convex’s own convex package has clients that call functions by their generated api references. Convex.Connect gives a Worker or Lambda the deployment’s URLs, so it can make one. It grants nothing: public functions need no key.

Effect.gen(function* () {
const convex = yield* Convex.Connect(Backend);
return {
fetch: Effect.gen(function* () {
const client = new ConvexHttpClient(yield* convex.url);
const rows = yield* Effect.tryPromise(() => client.query(api.messages.list, {}));
return yield* HttpServerResponse.json(rows);
}),
};
}).pipe(Effect.provide(Convex.ConnectHttp));

siteUrl is the address of your HTTP actions.