npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lilcdp

v0.1.0

Published

Playwright-free Chrome DevTools Protocol client for Cloudflare Workers (workerd) and Node 22+ — drive Browser Run with zero dependencies

Readme

lilcdp

Playwright-free Chrome DevTools Protocol client that runs inside Cloudflare Workers (workerd) and Node 22+. Zero runtime dependencies.

Driving Cloudflare Browser Run from a Worker, playwright-core is a dead end — it does a dynamic require of its own package.json that workerd cannot resolve. lilcdp speaks the ~dozen CDP commands an agent actually needs over a raw WebSocket, so the whole client is a few hundred lines you can read.

Quickstart (Worker + Browser Run)

import { connect, reconnect } from "lilcdp";

const endpoint = `wss://api.cloudflare.com/client/v4/accounts/${env.CLOUDFLARE_ACCOUNT_ID}/browser-rendering/devtools/browser`;

// keep_alive: the browser session survives disconnect() for 10 minutes
const browser = await connect(endpoint, { token: env.BROWSER_TOKEN, keepAliveMs: 600_000 });

const page = await browser.newPage("https://example.com");
const title = await page.evaluate<string>("document.title");
const png = await page.screenshot(); // base64
await page.click(100, 200);
await page.type("hello");
await page.press("Enter");
const axTree = await page.getFullAXTree(); // raw Accessibility domain passthrough

// Park the browser — the session (and page state) stays alive remotely:
await browser.disconnect();        // NOT close() — close() kills the session
const sessionId = browser.sessionId; // cf-browser-session-id upgrade header

// …later, from another step / another invocation:
const again = await reconnect(endpoint, sessionId!, { token: env.BROWSER_TOKEN });
const targets = await again.listTargets();
const page2 = await again.attach(targets.find((t) => t.type === "page")!.targetId);
// localStorage, window state, cookies — all still there

The workerd gotcha (why transport exists)

new WebSocket(url, { headers }) silently drops headers in Workers — so auth never reaches the endpoint. The default transport in workerd is the documented fetch-Upgrade pattern instead:

const resp = await fetch(httpsUrl, { headers: { Upgrade: "websocket", Authorization: `Bearer ${token}` } });
const ws = resp.webSocket; // status 101
ws.accept();

In Node the plain WebSocket constructor carries headers fine, so the default there is websocket. defaultTransportKind() exposes the pick. Tests (or exotic runtimes) can inject their own:

await connect(endpoint, { token, transport: async (url, headers) => ({ transport: mySocket }) });

The fetch-Upgrade handshake itself can't be exercised from Node (undici can't complete a WS upgrade via fetch), so it's covered by the live smoke script, not the unit tests.

API

  • connect(endpoint, { token, keepAliveMs?, requestTimeoutMs?, transport? }) → CdpBrowser
  • reconnect(endpoint, sessionId, opts) → CdpBrowser (path-segment reconnect, Browser Run verified)
  • browser: newPage(url?), attach(targetId), listTargets(), send(method, params, sessionId?) (raw escape hatch), onEvent(cb), disconnect(), close()
  • page: navigate, evaluate, screenshot("png"|"jpeg"), getFullAXTree(), click(x,y), type(text), press(key) (Enter/Tab/Backspace/Escape mapped; any key string works), close()

Development

pnpm test        # node:test, fake-socket transport — no network
pnpm smoke       # live Browser Run smoke (needs CLOUDFLARE_ACCOUNT_ID + token env)

MIT.