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

# Local sessions

> Configure your client for a local tvk dev session.

Create your client with the function you use throughout your frontend:

```ts theme={null}
import { createTableverseClient } from "@tableverse-kit/client";
import type { executor } from "token-race-engine";

type Game = typeof executor;

const client = createTableverseClient<Game>({
  viewer: "p1",
});
```

Start `tvk dev` before loading the frontend:

```bash theme={null}
pnpm -C engine dev
```

## Options

| Option       | Default                   | Purpose                                                                |
| ------------ | ------------------------- | ---------------------------------------------------------------------- |
| `serverUrl`  | `"http://localhost:5100"` | URL printed by `tvk dev`.                                              |
| `viewer`     | `"p1"`                    | Player ID used for local views and commands.                           |
| `players`    | `["p1"]`                  | Authoritative roster for the local match, in seating order.            |
| `seed`       | `"dev"`                   | Deterministic RNG seed for the local match.                            |
| `setupInput` | `undefined`               | Game configuration passed to `.setup()` when the local session starts. |

The first local connection initializes the in-memory session. Give it the roster and any setup input. The `setupInput` type is derived from the executor:

```ts theme={null}
const client = createTableverseClient<Game>({
  viewer: "p1",
  players: ["p1", "p2"],
  setupInput: {
    targetScore: 10,
  },
});
```

Restart `tvk dev` after changing the roster or setup input, or when you want a clean game.

## Wait for the connection

```ts theme={null}
try {
  await client.ready();
  render(client.getView());
} catch (error) {
  renderConnectionError(error);
}
```

Calls to `execute`, `discover`, or `getAvailableCommands` reject with a `TransportError` if the client is not ready.

## Use a different port

Start the server with `--port` and pass the same base URL to the client:

```bash theme={null}
pnpm -C engine exec tvk dev --port 5200
```

```ts theme={null}
const client = createTableverseClient<Game>({
  serverUrl: "http://localhost:5200",
});
```

Tableverse supplies the session URL, player identity, roster, seed, and setup input for published games. These options configure your local session.

<Card title="Render state changes" icon="arrow-right" href="/client/views-and-subscriptions">
  Subscribe and update your interface.
</Card>
