Install the client SDK
The client SDK is published as @pbvex/client. It is browser-neutral and only requires a fetch implementation.
Install
bash
npm install --global pbvex
npm install --save-dev pbvex
npm install @pbvex/clientThe CLI is installed globally so pbvex codegen is available directly. Keep its version aligned with the local pbvex authoring dependency, which supplies the server and validator imports used by a PBVex application.
Requirements
- Node.js 18+ or a modern browser.
- A
fetchimplementation. In Node 18+globalThis.fetchis used by default. In older environments, passfetchinClientOptions. crypto.subtleis required for realtime subscription id hashing.- TypeScript 5.0+ with
moduleResolution: 'NodeNext'is recommended for generatedFunctionReferencetypes.
Generate API references
In a PBVex project, run codegen to produce typed references:
bash
pbvex codegenThis writes pbvex/_generated/api.ts:
ts
import { api } from '../pbvex/_generated/api.js';
import { Client } from '@pbvex/client';
const client = new Client('http://localhost:8090');
const messages = await client.query(api.messages.list, { channel: 'general' });Peer relationship
@pbvex/client depends on @pbvex/protocol for the shared wire contract. You do not normally need to install @pbvex/protocol directly unless you are implementing a custom transport or authoring tooling.