HttpClient is an Effect service that wraps Convex’s ConvexHttpClient. It provides query, mutation, and action methods that accept refs and automatically encode args and decode return values through the schemas defined in your function specs. Works in any JavaScript runtime that supports fetch.
Setup
Create theHttpClient layer by passing your Convex deployment URL.
HttpClient service.
Calling functions
Use theHttpClient service inside Effect.gen to call your functions with refs, the same way you would with @confect/react hooks or @confect/test.
Effect that can fail with HttpClientError (wrapping transport-level errors) or ParseResult.ParseError (if schema encoding or decoding fails).
Authentication
Set or clear the auth token before making authenticated requests.Running programs
Provide theHttpClient layer when running your program.
Differences from ConvexHttpClient
ConvexHttpClient | HttpClient |
|---|---|
Functions referenced via api.module.fn | Functions referenced via refs |
| Args passed directly to Convex as-is | Args are schema-encoded from Type to Encoded before sending |
| Return values received directly as-is | Return values are schema-decoded from Encoded to Type |
Methods return Promise | Methods return Effect with typed errors |