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

r2pub

v0.1.0

Published

Upload files to a public Cloudflare R2 bucket and print the final public URL.

Readme

r2pub

Upload one file to a public Cloudflare R2 bucket and print the final public URL.

r2pub is a small CLI for URL-first workflows. It is especially useful when another tool needs a public asset URL on stdout after upload, such as openzca voice publishing.

Features

  • Upload a local file to Cloudflare R2 with a generated object key
  • Print the final public URL to stdout
  • Store non-secret config in a local config file
  • Use macOS Keychain for secrets on macOS
  • Support environment-variable credentials on macOS, Linux, and Windows
  • Verify configuration and bucket access with doctor

Requirements

  • Node.js 22+
  • A Cloudflare R2 bucket
  • A public bucket URL or custom domain
  • R2 S3 credentials with object read/write access

Install

Clone and link locally:

npm install
npm link

Then verify:

r2pub --help

Setup

macOS

Use init to save non-secret config and store credentials in Keychain:

r2pub init

Linux / Windows

r2pub can use environment variables for credentials. init will still save the non-secret config file, but it will not try to persist secrets outside macOS Keychain.

Set one of these pairs:

export R2PUB_ACCESS_KEY_ID="..."
export R2PUB_SECRET_ACCESS_KEY="..."

or:

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."

Then run:

r2pub init

Values you need during setup

  • accountId: your Cloudflare account ID
  • bucket: the R2 bucket name
  • publicBaseUrl: the public base URL for the bucket, for example https://<bucket>.r2.dev
  • prefix: optional object key prefix, default voice

Usage

Upload one file:

r2pub ./note.m4a

Print the computed URL without uploading:

r2pub --dry-run ./note.m4a

Override the prefix or object key:

r2pub --prefix uploads ./note.m4a
r2pub --key voice/custom/note.m4a ./note.m4a

Show config:

r2pub config show

Check readiness:

r2pub doctor

doctor exits with a non-zero code if config, credentials, or bucket access are missing.

OpenZCA Integration

Set:

export OPENZCA_VOICE_PUBLISH_CMD="r2pub"

Then openzca msg voice <threadId> ./file.mp3 can normalize the local file, upload it through r2pub, and send the returned public URL.

Config and Credential Storage

Non-secret config:

  • macOS/Linux default: ~/.config/r2pub/config.json
  • Windows default: %APPDATA%\\r2pub\\config.json
  • Linux also respects XDG_CONFIG_HOME

Credential lookup order:

  1. R2PUB_ACCESS_KEY_ID / R2PUB_SECRET_ACCESS_KEY
  2. AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
  3. macOS Keychain entries saved by r2pub init

Exit Behavior

  • Successful upload prints exactly one URL to stdout
  • Errors go to stderr
  • doctor returns exit code 1 when the setup is not healthy

Development

npm test
node src/cli.js --help

License

MIT