@yydb/yydb-client
v0.1.6
Published
TypeScript client for the YYDB WebSocket and TCP wire protocol
Maintainers
Readme
@yydb/yydb-client
TypeScript client for the YY wire protocol over WebSocket or TCP. Use it when yydb serve already runs (from
@yydb/yydb CLI or another host) and you only need the client surface —
browser, WebUI, Electron renderer, or a thin Node process.
Exports
| Import | Transport | Typical use |
|--------------------------|-------------------|--------------------|
| @yydb/yydb-client | WebSocket /wire | Browsers and WebUI |
| @yydb/yydb-client/node | TCP or WebSocket | Node and Electron |
Frame helpers (encodeFrame, MessageType, …) are exported for tools and tests.
Example
Start a host (from @yydb/yydb or the yydb CLI):
yydb serve app.yydb --bind 127.0.0.1:7700Browser / WebSocket
import {Client} from "@yydb/yydb-client";
const db = await Client.connect("ws://127.0.0.1:7700/wire");
await db.ensureSchema(1, "table Setting { @@id: uuid, key: utf8, value: utf8 }");
await db.put("theme", "dark");
console.log(await db.get("theme"));
db.close();Node TCP
import {connect} from "@yydb/yydb-client/node";
const db = await connect("127.0.0.1:7700");
console.log(await db.info());
db.close();To open a local .yydb file without managing a server, use @yydb/yydb
instead.
The client accepts hosts that announce YYDB or YYDS on the shared wire. Connect only to hosts you control — normally
127.0.0.1 or localhost.
Protocol details: yydb-serve-protocol
in @yydb/yydb-skills.
