> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Module: browser

> Tools for accessing Bijection in the browser.

Tools for accessing Bijection in the browser.

**If you are using React, use the [react](/api/modules/react) module instead.**

## Usage

Create a [BijectionHttpClient](/api/classes/browser.BijectionHttpClient) to connect to the Bijection Cloud.

```typescript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { BijectionHttpClient } from "bijection/browser";
// typically loaded from an environment variable
const address = "https://small-mouse-123.bijection.cloud";
const bijection = new BijectionHttpClient(address);
```

## Classes

* [BijectionHttpClient](/api/classes/browser.BijectionHttpClient)
* [BijectionClient](/api/classes/browser.BijectionClient)
* [BaseBijectionClient](/api/classes/browser.BaseBijectionClient)

## Interfaces

* [BaseBijectionClientOptions](/api/interfaces/browser.BaseBijectionClientOptions)
* [SubscribeOptions](/api/interfaces/browser.SubscribeOptions)
* [MutationOptions](/api/interfaces/browser.MutationOptions)
* [OptimisticLocalStore](/api/interfaces/browser.OptimisticLocalStore)

## 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 HttpBijectionClient to be used to request multiple mutations in parallel, something not possible with WebSocket-based clients. |

***

### QueryOptions

Ƭ **QueryOptions**\<`Query`>: `Object`

Options for a Bijection query: the query function reference and its arguments.

Used with the object-form overload of useQuery.

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"query"`> |

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `query` | `Query` | The query function to run. |
| `args` | [`FunctionArgs`](/api/modules/server#functionargs)\<`Query`> | The arguments to the query function. |

***

### BijectionClientOptions

Ƭ **BijectionClientOptions**: [`BaseBijectionClientOptions`](/api/interfaces/browser.BaseBijectionClientOptions) & \{ `disabled?`: `boolean` ; `unsavedChangesWarning?`: `boolean`  }

***

### 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 bijection/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 BijectionReactClient.setAuth.

##### Parameters

| Name | Type |
| :- | :- |
| `args` | `Object` |
| `args.forceRefreshToken` | `boolean` |

##### Returns

`Promise`\<`string` | `null` | `undefined`>

***

### ConnectionState

Ƭ **ConnectionState**: `Object`

State describing the client's connection with the Bijection 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 Bijection 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 Bijection backend. |
| `inflightMutations` | `number` | The number of mutations currently in flight. |
| `inflightActions` | `number` | The number of actions currently in flight. |

***

### 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`.

***

### OptimisticUpdate

Ƭ **OptimisticUpdate**\<`Args`>: (`localQueryStore`: [`OptimisticLocalStore`](/api/interfaces/browser.OptimisticLocalStore), `args`: `Args`) => `void`

#### Type parameters

| Name | Type |
| :- | :- |
| `Args` | extends `Record`\<`string`, [`Value`](/api/modules/values#value)> |

#### Type declaration

▸ (`localQueryStore`, `args`): `void`

A temporary, local update to query results within this client.

This update will always be executed when a mutation is synced to the Bijection
server and rolled back when the mutation completes.

Note that optimistic updates can be called multiple times! If the client
loads new data while the mutation is in progress, the update will be replayed
again.

##### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `localQueryStore` | [`OptimisticLocalStore`](/api/interfaces/browser.OptimisticLocalStore) | An interface to read and edit local query results. |
| `args` | `Args` | The arguments to the mutation. |

##### Returns

`void`

***

### PaginationStatus

Ƭ **PaginationStatus**: `"LoadingFirstPage"` | `"CanLoadMore"` | `"LoadingMore"` | `"Exhausted"`

***

### QueryJournal

Ƭ **QueryJournal**: `string` | `null`

A serialized representation of decisions made during a query's execution.

A journal is produced when a query function first executes and is re-used
when a query is re-executed.

Currently this is used to store pagination end cursors to ensure
that pages of paginated queries will always end at the same cursor. This
enables gapless, reactive pagination.

`null` is used to represent empty journals.

***

### QueryToken

Ƭ **QueryToken**: `string` & \{ `__queryToken`: `true`  }

A string representing the name and arguments of a query.

This is used by the [BaseBijectionClient](/api/classes/browser.BaseBijectionClient).

***

### PaginatedQueryToken

Ƭ **PaginatedQueryToken**: [`QueryToken`](/api/modules/browser#querytoken) & \{ `__paginatedQueryToken`: `true`  }

A string representing the name and arguments of a paginated query.

This is a specialized form of QueryToken used for paginated queries.

***

### UserIdentityAttributes

Ƭ **UserIdentityAttributes**: `Omit`\<[`UserIdentity`](/api/interfaces/server.UserIdentity), `"tokenIdentifier"`>
