Client SDK
Embed hostc in your own product.
Use @hostc/client when tunnels need to live inside a desktop app, daemon, custom CLI, or Node.js runtime.
Install
The SDK is the public integration boundary. Application code only needs @hostc/client.
npm
npm install @hostc/clientNode.js integration
Create a client, point it at your hostc server, and forward traffic to a local origin.
Example
import { HostcClient, localOriginAdapter } from "@hostc/client";
const client = new HostcClient({
serverUrl: "https://hostc.example.com",
upstream: localOriginAdapter({
origin: "http://127.0.0.1:3000",
}),
});
client.on("ready", ({ publicUrl }) => {
console.log(`Tunnel ready: ${publicUrl}`);
});
client.on("reconnecting", ({ reason }) => {
console.log(`Reconnecting: ${reason}`);
});
await client.start();Protocol boundary
The SDK uses the v4 protocol internally, but protocol frames and stream internals are not public SDK API.
Use the SDK, not the protocol package.
@hostc/protocol is the internal wire-contract source of truth. It is bundled into @hostc/client so your app only needs one public dependency.