Module: browser
Tools for accessing Convex in the browser.
If you are using React, use the react module instead.
Usage
Create a ConvexHttpClient to connect to the Convex Cloud.
import { ConvexHttpClient } from "convex/browser";
// typically loaded from an environment variable
const address = "https://small-mouse-123.convex.cloud";
const convex = new ConvexHttpClient(address);
Classes
Interfaces
Type Aliases
HttpMutationOptions
Ƭ HttpMutationOptions: Object
Type declaration
| Name | Type | Description |
|---|---|---|
skipQueue | boolean | Skip the default queue of mutations and run this immediately. This allows the same HttpConvexClient to be used to request multiple mutations in parallel, something not possible with WebSocket-based clients. |
Defined in
ConvexClientOptions
Ƭ ConvexClientOptions: BaseConvexClientOptions & { disabled?: boolean ; unsavedChangesWarning?: boolean }
Defined in
AuthTokenFetcher
Ƭ AuthTokenFetcher: (args: { forceRefreshToken: boolean }) => Promise<string | null | undefined>
Type declaration
▸ (args): Promise<string | null | undefined>
An async function returning a JWT. Depending on the auth providers configured in convex/auth.config.ts, this may be a JWT-encoded OpenID Connect Identity Token or a traditional JWT.
forceRefreshToken is true if the server rejected a previously
returned token or the token is anticipated to expiring soon
based on its exp time.
See ConvexReactClient.setAuth.
Parameters
| Name | Type |
|---|---|
args | Object |
args.forceRefreshToken | boolean |
Returns
Promise<string | null | undefined>
Defined in
browser/sync/authentication_manager.ts:25
ConnectionState
Ƭ ConnectionState: Object
State describing the client's connection with the Convex backend.
Type declaration
| Name | Type | Description |
|---|---|---|
hasInflightRequests | boolean | - |
isWebSocketConnected | boolean | - |
timeOfOldestInflightRequest | Date | null | - |
hasEverConnected | boolean | True if the client has ever opened a WebSocket to the "ready" state. |
connectionCount | number | The number of times this client has connected to the Convex backend. A number of things can cause the client to reconnect -- server errors, bad internet, auth expiring. But this number being high is an indication that the client is having trouble keeping a stable connection. |
connectionRetries | number | The number of times this client has tried (and failed) to connect to the Convex backend. |
inflightMutations | number | The number of mutations currently in flight. |
inflightActions | number | The number of actions currently in flight. |
Defined in
FunctionResult
Ƭ FunctionResult: FunctionSuccess | FunctionFailure
The result of running a function on the server.
If the function hit an exception it will have an errorMessage. Otherwise
it will produce a Value.
Defined in
browser/sync/function_result.ts:11
OptimisticUpdate
Ƭ OptimisticUpdate<Args>: (localQueryStore: OptimisticLocalStore, args: Args) => void
Type parameters
| Name | Type |
|---|---|
Args | extends Record<string, Value> |