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

@theholocron/cloudflare-client

v1.24.0

Published

A TypeScript client for the Cloudflare API

Readme

@theholocron/cloudflare-client

TypeScript client for the Cloudflare v4 API.

Install

pnpm add @theholocron/cloudflare-client

Usage

import { createCloudflareClient } from "@theholocron/cloudflare-client";

const cf = createCloudflareClient({ token: process.env.CLOUDFLARE_API_TOKEN! });

// Verify token
const verification = await cf.tokens.verify();

// Look up a zone by domain name
const zones = await cf.zones.list({ name: "example.com" });
const zoneId = zones[0].id;

// List DNS records in a zone
const records = await cf.dns.list(zoneId);

// Create a DNS record
const record = await cf.dns.create(zoneId, {
  type: "CNAME",
  name: "www",
  content: "cname.vercel-dns.com",
  ttl: 1,
  proxied: false,
});

// Update a DNS record
await cf.dns.update(zoneId, record.id, { content: "new.target.com" });

// Delete a DNS record
await cf.dns.delete(zoneId, record.id);

// Create a Cloudflare Tunnel
const tunnel = await cf.tunnels.create("my-account-id", { name: "my-tunnel" });

// Get the tunnel connector token
const tunnelToken = await cf.tunnels.token("my-account-id", tunnel.id);

// Read/write tunnel ingress configuration
const { config } = await cf.tunnels.getConfig("my-account-id", tunnel.id);
await cf.tunnels.putConfig("my-account-id", tunnel.id, {
  ingress: [{ hostname: "app.example.com", service: "http://localhost:3000" }, { service: "http_status:404" }],
});

// Delete a tunnel (cascade removes all associated routes and DNS records)
await cf.tunnels.delete("my-account-id", tunnel.id);

Usage — Pages

const cf = createCloudflareClient({ token: process.env.CLOUDFLARE_API_TOKEN! });
const ACCOUNT = process.env.CLOUDFLARE_ACCOUNT_ID!;

// Ensure a Pages project exists
const existing = await cf.pages.getProject(ACCOUNT, "my-docs-preview");

// Create a project
const project = await cf.pages.createProject(ACCOUNT, {
  name: "my-docs-preview",
  production_branch: "main",
});

// Trigger a preview deployment for a branch
const deployment = await cf.pages.createDeployment(ACCOUNT, "my-docs-preview", "feat/my-feature");
console.log(deployment.url); // https://<hash>.my-docs-preview.pages.dev

// Get deployment status
const status = await cf.pages.getDeployment(ACCOUNT, "my-docs-preview", deployment.id);

// Add a custom domain to the project
await cf.pages.addDomain(ACCOUNT, "my-docs-preview", "*.preview.example.dev");

// List custom domains
const domains = await cf.pages.listDomains(ACCOUNT, "my-docs-preview");

// Set an env var on a project
await cf.pages.updateProject(ACCOUNT, "my-docs-preview", {
  deployment_configs: {
    preview: { env_vars: { MY_VAR: { value: "hello", type: "plain_text" } } },
    production: { env_vars: {} },
  },
});

Usage — Workers

const cf = createCloudflareClient({ token: process.env.CLOUDFLARE_API_TOKEN! });
const ACCOUNT = process.env.CLOUDFLARE_ACCOUNT_ID!;

// Deploy (or update) a Worker script
await cf.workers.putScript(ACCOUNT, "my-worker", "export default { fetch() { … } };");

// Set a secret — one call both stores the encrypted value and binds it as
// `env.MY_SECRET` in the Worker; values are write-only, never echoed back
await cf.workers.putSecret(ACCOUNT, "my-worker", "MY_SECRET", "shh");

// List secret names bound to a script (no values)
const secrets = await cf.workers.listSecrets(ACCOUNT, "my-worker");

// Remove a secret binding
await cf.workers.deleteSecret(ACCOUNT, "my-worker", "MY_SECRET");

// Route management — zone-scoped
const routes = await cf.workers.listRoutes("zone-id");
await cf.workers.createRoute("zone-id", "example.com/*", "my-worker");
await cf.workers.updateRoute("zone-id", routes[0].id, "example.com/*", "my-worker");

Auth

Create an API Token with the permissions your use case requires:

| Use case | Required permissions | | ------------------ | -------------------------------- | | DNS management | Zone:Read, DNS:Edit | | Tunnel management | Account:Cloudflare Tunnel:Edit | | Pages deployments | Account:Cloudflare Pages:Edit | | Workers + secrets | Account:Workers Scripts:Edit | | Worker routes | Zone:Workers Routes:Edit | | Token verification | User:API Tokens:Read |

Pass the token directly or via the CLOUDFLARE_API_TOKEN environment variable.