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

@kilog/wrangler-plugin

v1.3.1

Published

Cloudflare Wrangler / @cloudflare/vite-plugin integration for kilog structured logging

Readme

@kilog/wrangler-plugin

Capture console, fetch, and uncaught errors from Cloudflare Workers running under wrangler dev (workerd), and ship them into the local .kilog/raw/<date>.workerd.jsonl store. Local development onlywrangler deploy produces an unmodified bundle (the worker no-ops without a receiver URL).

How it works

The worker can't write files directly (workerd has no fs). Instead, an instrumented wrapper around console / fetch / global error events POSTs each event to a localhost HTTP receiver running in the dev driver process, which writes them to .kilog/raw/.

The receiver URL is baked into the worker bundle (via --define or a Vite plugin), so the worker has no runtime dependency on a specific port or env binding once it's built.

Setup A: With Vite (@cloudflare/vite-plugin as the dev proxy)

Use this when Vite drives your dev server and @cloudflare/vite-plugin runs the worker inside it. Vite's dev server hosts the /__kilog receiver in the same process — no extra launcher needed.

// vite.config.ts
import { defineConfig } from "vite";
import { cloudflare } from "@cloudflare/vite-plugin";
import kilogWranglerPlugin from "@kilog/wrangler-plugin";

export default defineConfig({
  plugins: [cloudflare(), kilogWranglerPlugin()],
});

kilogWranglerPlugin():

  • registers a POST /__kilog middleware on the Vite dev server (writes events to .kilog/raw/)
  • auto-injects import "@kilog/wrangler-plugin/instrument" and the resolved receiver URL into the worker entry — no code changes in your worker

Worker entry detection is heuristic (looks for export default { fetch... } near the top of source files outside node_modules). If your entry doesn't match the heuristic, pass workerEntries: ["src/your-entry.ts"] to the plugin.

Setup B: Without Vite (plain wrangler dev)

Use this when you run wrangler dev directly — no Vite, no @cloudflare/vite-plugin. A small CLI kilog-wrangler wraps wrangler: it starts a localhost receiver, then exec's wrangler dev with two flags so the worker knows where to ship events.

Worker side — explicit (import + wrapper, no auto-inject):

// src/index.ts
import "@kilog/wrangler-plugin/instrument";
import { withKilog } from "@kilog/wrangler-plugin/with-kilog";

export default withKilog({
  async fetch(req, env, ctx) {
    console.log("hello from workerd");
    return new Response("ok");
  },
});

Dev script — use the kilog-wrangler launcher:

{ "scripts": { "dev": "kilog-wrangler dev" } }

What kilog-wrangler does:

  1. starts a localhost receiver on a random port
  2. exec's wrangler dev with --var KILOG_RECEIVER_URL:http://127.0.0.1:<port>/__kilog and --define __KILOG_RECEIVER_URL__:"http://127.0.0.1:<port>/__kilog"
  3. forwards stdin/stdout/stderr, signals, and the exit code

withKilog lifts env.KILOG_RECEIVER_URL into globalThis.__KILOG_RECEIVER_URL__ per request, so the top-level instrument import always has a receiver target.

Which setup?

| You're using… | Setup | | ---------------------------------------------------------------------------- | ----- | | Vite + @cloudflare/vite-plugin (Vite serves your worker via its dev proxy) | A | | wrangler dev directly (no Vite) | B |

You can't easily mix the two — Setup A relies on Vite's middleware, Setup B relies on the kilog-wrangler launcher. Pick whichever matches how you already run the worker.

Plugin options (Setup A)

kilogWranglerPlugin({
  terminal: "warn", // mirror warn+/error events to stdout
  persist: true, // keep previous logs across dev restarts
  workerEntries: ["src/index.ts"], // override entry detection
});

| Option | Type | Default | Description | | --------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------ | | terminal | boolean \| LogLevel | false | Print captured events to stdout. true = all; a level filters by level field. | | persist | boolean | false | Keep previous logs across dev server restarts. | | workerEntries | string[] | — | Explicit entry paths to inject into. Defaults to a heuristic export default { fetch... } scan. |

CLI flags (Setup B — kilog-wrangler)

kilog-wrangler forwards everything to wrangler verbatim except a few flags it consumes itself:

| Flag | Description | | -------------------------------- | ----------------------------------------------------------- | | --kilog-persist | Keep previous logs across runs (same as KILOG_PERSIST=1). | | --kilog-terminal[=true\|level] | Mirror events to stdout (optionally filtered by level). |

Everything else (dev, --port, --local, custom entry path, etc.) is passed to wrangler unchanged.

Examples