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

@splitch/cloudflare

v0.1.2

Published

Customer-owned Cloudflare Worker for durable local Splitch evaluation

Readme

@splitch/cloudflare

Splitch Flag and Experiment evaluation inside a Worker you own. @splitch/cloudflare is deployed into your own Cloudflare account, backed by a SQLite Durable Object. splitch pushes configuration to it; your application Workers evaluate through a service binding, so no evaluation crosses the public Internet. One deployment is bound to one splitch Environment.

Use it when you already run on Workers and want local latency and durable Assignment state. A Worker that is happy with a network round-trip should use the ordinary server client (@splitch/sdk) instead.

Install

npm install @splitch/cloudflare
npm install --global @splitch/cli

Node 24 or newer for the CLI that drives setup. The package itself runs in the Workers runtime.

Setup

Setup is one command. Before running it you need:

| Requirement | Why | | -------------------------------------------------- | ---------------------------------------------------------------------------- | | SPLITCH_API_KEY exported | The Environment's API Key. The name is exact; setup reads no other variable. | | Wrangler 4 | Setup runs the App's own Wrangler, or the wrangler on your PATH. | | wrangler login | Setup deploys the integration Worker into your account. | | An application wrangler.jsonc or wrangler.json | Setup adds the SPLITCH service binding to it. |

export SPLITCH_API_KEY=sk_...
splitch cloudflare setup --env production

The command fails before it mutates anything if the API Key, the application Wrangler config, the Wrangler session, or the Cloudflare account is unavailable. Once past that gate it:

  1. writes .splitch/cloudflare/production/{wrangler.jsonc,worker.ts,state.json} and appends .splitch/cloudflare/*/state.json to your .gitignore,
  2. deploys the integration Worker as splitch-config-production,
  3. stores SPLITCH_API_KEY and SPLITCH_PUSH_SECRET as Wrangler secrets on that Worker,
  4. registers the deployment with splitch and waits (up to 60 seconds) until the pushed configuration version is applied,
  5. adds the SPLITCH service binding to your application's Wrangler environment and reruns wrangler types.

The state file is written mode 0600. An exact rerun discovers and repairs the existing installation. Reusing the Environment name with a different API Key, account, endpoint, or secret fails IDEMPOTENCY_KEY_CONFLICT rather than quietly rebinding it.

Evaluate from your Worker

wrangler types makes env.SPLITCH a typed service binding. The same call handles ordinary Flags, Targeting Rules, baseline rollouts, live Experiments, and holdover replay.

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const enabled = await env.SPLITCH.evaluate("new-checkout", {
      targetingKey: "customer-123",
      idempotencyKey: crypto.randomUUID(),
      defaultValue: false,
    });

    return new Response(enabled ? "new" : "current");
  },
};

| Method | Returns | Fires an Exposure | | ----------------- | -------------------------------- | ----------------- | | evaluate | the Variant value | yes | | evaluateDetails | full ResolutionDetails | yes | | status | installation and delivery health | no |

targetingKey and idempotencyKey are required; idType defaults to user, attributes to {}, and defaultValue to false. Both evaluation methods are Exposure-bearing, because an application RPC is an explicit encounter. There is no remote, experiment, sendExposure, or fallback option. Use status() for health checks, never an evaluation accessor.

Retrying with the same idempotencyKey and identical input returns the stored result and creates no second Exposure. Reusing that key with different input fails loud rather than serving the stale answer.

Before the first push lands

A Worker that has not yet received its first configuration push resolves to your defaultValue with errorCode: "PROVIDER_NOT_READY". That is the one code this surface adds to the shared catalog, and it is reported rather than disguised: setup waits for the applied version precisely so your first real request is not the one that discovers it.

Operate it

splitch cloudflare status --env production   # worker name, endpoint, state, versions, pending deliveries
splitch cloudflare remove --env production   # revoke delivery, unbind SPLITCH, delete the Worker

remove revokes splitch delivery first, then removes the service binding and the integration Worker. It never deletes an unrelated Worker or an untracked file.

Targeting keys are hashed with an installation-local key held only in Durable Object storage. A raw Targeting Key exists in a pending Exposure row only until that row is accepted, terminal, or 24 hours old.

Exports

| Import | What it is | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | | @splitch/cloudflare | Types only: SplitchCloudflareService, CloudflareEvaluationContext, CloudflareResolutionDetails, CloudflareRuntimeStatus | | @splitch/cloudflare/worker | The Worker entrypoint and its SplitchState Durable Object; re-exported by the generated worker.ts |

You do not import /worker by hand. splitch cloudflare setup generates the entry that does.

Links