// DOCUMENTATION

SDK quickstart

Connect to Koko and automate pages with the TypeScript SDK.

Getting Started

The Koko SDK (koko-sdk) talks directly to CDP over WebSocket. The public API is modeled after Playwright so scripts port with minimal changes.

Install

npm install koko-sdk

Launch Koko from Node

Prefer Browser.launch() over manual serve — the SDK picks a free port, spawns the binary, and waits for CDP readiness.

import { Browser } from "koko-sdk";

const launched = await Browser.launch({
  binary: "/path/to/koko",
  profile: "chrome-macos-catalina", // optional antidetect profile
});

const page = await launched.browser.newPage();
await page.goto("https://example.com", { waitUntil: "domcontentloaded" });
console.log(await page.title(), await page.url());

await launched.close();

Connect to an existing CDP server

const browser = await Browser.connect("http://127.0.0.1:9222");
const context = await browser.newContext({
  viewport: { width: 1280, height: 720 },
});
const page = await context.newPage();
await page.goto("https://example.com");
await browser.close();

Locators (Playwright-style)

await page.getByRole("link", { name: "More information" }).click();
await page.getByLabel("Search").fill("Koko browser");
await page.getByRole("button", { name: "Search" }).click();

Koko-only navigation wait

waitUntil: "done" is stricter than Playwright networkidle — load + network idle + document complete. Default for MCP and crawl helpers.

await page.goto(url, { waitUntil: "done" });

Next steps