Skip to main content

Class: ConvexHttpClient

browser.ConvexHttpClient

A Convex client that runs queries and mutations over HTTP.

This is appropriate for server-side code (like Netlify Lambdas) or non-reactive webapps.

If you're building a React app, consider using ConvexReactClient instead.

Constructors

constructor

new ConvexHttpClient(clientConfig)

Parameters

NameType
clientConfigClientConfiguration

Methods

backendUrl

backendUrl(): string

Obtain the ConvexHttpClient's URL to its backend.

Returns

string

The URL to the Convex backend, including the client's API version.


setAuth

setAuth(value): void

Set the authentication token to be used for subsequent queries and mutations.

Should be called whenever the token changes (i.e. due to expiration and refresh).

Parameters

NameTypeDescription
valuestringJWT-encoded OpenID Connect identity token.

Returns

void


clearAuth

clearAuth(): void

Clear the current authentication token if set.

Returns

void


query

query<F>(name): Query<F>

Construct a new Query.

Type parameters

NameType
Fextends (...args: any[]) => Promise<any>

Parameters

NameTypeDescription
namestringThe name of the query function.

Returns

Query<F>

The Query object with that name.


mutation

mutation<F>(name): Mutation<F>

Construct a new Mutation.

Type parameters

NameType
Fextends (...args: any[]) => Promise<any>

Parameters

NameTypeDescription
namestringThe name of the mutation function.

Returns

Mutation<F>

The Mutation object with that name.