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

# Clients

> Connect from React or native Rust.

CharDB includes a React client for browser applications and a native Rust client for services and command-line programs in this repository. Registry publication is still pending. Both use registered query and mutation handles rather than accepting SQL from the caller.

## React

The React client lives in `packages/react` and is wired into the generated workspace. The npm package is not public yet.

Configure the client with the same public URL that serves Better Auth and the CharDB Worker:

```tsx src/web/App.tsx theme={null}
import { anonymousClient, jwtClient, organizationClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import { createChardbReactClient } from "@chardb/react";

export const db = createChardbReactClient({
  url: window.location.origin,
  ownership: "organization",
  auth: ({ baseURL }) => createAuthClient({
    baseURL,
    plugins: [anonymousClient(), organizationClient(), jwtClient()],
  }),
});
```

`createChardbReactClient` uses that URL for Better Auth, live WebSockets, and organization file routes. It preserves Better Auth's inferred client plugins and adds the verified user or active organization to query and mutation arguments.

Follow [Live queries](/live-queries) for the client setup and [Files](/files) for the organization-scoped file API.

## Rust

The `chardb-client` crate lives in `rust/chardb` and provides blocking and runtime-neutral async APIs over protocol version 3. The crate is not public on crates.io yet.

Typed `Query<Arguments, Row>` and `Mutation<Arguments, Output>` handles bind each server reference to its Serde request and response types. The default build includes both client styles and Rustls; optional features select native roots or JSON Schema introspection.

The Rust client supports registered live queries, mutations, reconnects, mutation replay, and auth refresh. Your application must obtain the initial Better Auth JWT and provide refreshed JWTs when the client requests one. The crate does not perform sign-in. It also does not implement files, vectors, `workers-rs`, or `wasm32` transport.

The crate README at `rust/chardb/README.md` covers connection, TLS, timeout, and feature details.
