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

effect-platform-cloudflare

v0.1.0

Published

Effect HTTP router runtime for Cloudflare Workers

Readme

effect-platform-cloudflare

Run an Effect HTTP router as a Cloudflare Worker without coupling the application to a deployment framework.

bun add effect-platform-cloudflare [email protected]

The 0.1.x line is tested against Effect 4.0.0-beta.98, which is the minimum supported peer version. Later Effect releases are accepted by the package peer range.

import { Context, Effect } from "effect";
import { HttpRouter, HttpServerResponse } from "effect/unstable/http";
import { HttpWorker } from "effect-platform-cloudflare";

interface Env {
  readonly API_ORIGIN: string;
}

class WorkerBindings extends Context.Service<WorkerBindings, Env>()("app/WorkerBindings") {}

const AppLayer = HttpRouter.add(
  "GET",
  "/",
  Effect.gen(function* () {
    const env = yield* WorkerBindings;
    return HttpServerResponse.text(`upstream: ${env.API_ORIGIN}`);
  }),
);

const fetch = HttpWorker.toWebHandler(AppLayer, {
  environment: WorkerBindings,
});

export default { fetch } satisfies ExportedHandler<Env>;

HttpWorker.toWebHandler is the Cloudflare equivalent of Effect's HttpRouter.toWebHandler. It takes the router application layer directly, adds the router runtime, renders failures, logs requests by default, and returns a standard Worker fetch handler.

The application owns the environment service key. The handler infers its Env parameter from that key and provides the exact bindings through the Effect context without a cast. Both Context.Service and Context.Reference keys are supported.

Layer lifetimes

The application layer is built in a fresh scope for every request. Put request-owned resources such as database connections in that graph so they cannot cross workerd event contexts.

Use isolateLayer only for services that are safe to share across every request handled by the same Worker isolate:

const fetch = HttpWorker.toWebHandler(AppLayer, {
  environment: WorkerBindings,
  isolateLayer: HostServicesLayer,
});

Successful isolate initialization is cached. A failed build is closed and retried on the next request. The isolate context deliberately omits Effect's CurrentMemoMap, so request-time layer builds receive a fresh memo map.

HTTP behavior

The handler uses Effect's HTTP server machinery for failure rendering, tracing, response logging, HEAD requests, and streaming scope transfer. Set disableLogger: true to disable the default response logger, or pass middleware using the same shape accepted by Effect's router Web handler.

Every request is interrupted with HttpServerError.ClientAbort.annotation when its Web Request signal aborts. Its full Effect Exit is registered with Cloudflare's native ExecutionContext.waitUntil, allowing finalizers to finish even when the caller disconnects.

Background work

The Effect service is named WorkerExecutionContext and exposes only one operation:

const program = Effect.gen(function* () {
  const context = yield* WorkerExecutionContext;
  yield* context.waitUntil(fullyProvidedEffect);
});

The Effect passed to waitUntil must have no remaining requirements. It runs in an independent scope, and the promise registered with Cloudflare never rejects. The native execution context is not exposed through the Effect service.