Overview
ConvexHttpClient is a stateful client that runs queries and mutations over HTTP instead of WebSocket. This is appropriate for server-side code (like serverless functions, API routes, or backend services) or non-reactive web applications.
Constructor
Create a newConvexHttpClient instance.
Parameters
string
required
The URL of your Convex deployment, often provided by an environment variable.
For example:
https://small-mouse-123.convex.cloudobject
Optional configuration object for the client.
Methods
query
Execute a Convex query function.FunctionReference<'query'>
required
A function reference for the public query to run, like
api.dir1.dir2.filename.func.object
An arguments object for the query. If omitted, the arguments will be
{}.mutation
Execute a Convex mutation function. Mutations are queued by default.FunctionReference<'mutation'>
required
A function reference for the public mutation to run.
object
An arguments object for the mutation. If omitted, the arguments will be
{}.HttpMutationOptions
By default, mutations are queued and executed sequentially. This ensures mutations are applied in order.
Set
skipQueue: true to execute mutations in parallel.action
Execute a Convex action function. Actions are not queued.FunctionReference<'action'>
required
A function reference for the public action to run.
object
An arguments object for the action. If omitted, the arguments will be
{}.setAuth
Set the authentication token to be used for subsequent queries and mutations.string
required
JWT-encoded OpenID Connect identity token.
Should be called whenever the token changes (e.g., due to expiration and refresh).
clearAuth
Clear the current authentication token if set.Properties
url
Return the address for this client.Not guaranteed to match the address used in the constructor as it may be canonicalized.