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

@letsroti/sourceembed

v1.0.2

Published

Store embed JSON to Cloudflare R2 and return a public URL

Readme

@letsroti/sourceembed

A small utility for storing raw text (typically embed JSON) in Cloudflare R2 and returning a public URL.

Useful for hosting embed payloads, temporary JSON data, or shareable configuration files without building custom storage logic.

The library uploads text to an R2 bucket using the S3-compatible API, generates a UUID-based filename, and returns a public URL using your configured domain.

Installation

Install the package using your preferred Node.js package manager.

npm install @letsroti/sourceembed

or

yarn add @letsroti/sourceembed

or

pnpm add @letsroti/sourceembed

Requirements

This package only needs two things.

Cloudflare R2 Credentials

Valid Cloudflare R2 API credentials with permission to upload objects to your bucket.

Required values:

  • Access Key ID
  • Secret Access Key
  • R2 S3-compatible endpoint URL

Example endpoint format:

https://<account-id>.r2.cloudflarestorage.com

These credentials are used by the AWS S3 client to upload files to your R2 bucket.

Public Domain

You must also have a public domain that serves files from your R2 bucket.

Example:

raw.example.com

Uploaded files will be returned as URLs in this format:

https://raw.example.com/<uuid>.json

Usage

Import and Initialize

import { SourceEmbed } from '@letsroti/sourceembed';

const sourceEmbed = new SourceEmbed({
  accessKeyId: process.env.R2_ACCESS_KEY_ID!,
  secretAccessKey: process.env.R2_ACCESS_KEY_SECRET!,
  endpoint: process.env.R2_ENDPOINT_URL!,
  bucket: process.env.R2_BUCKET!,
  publicDomain: process.env.R2_PUBLIC_DOMAIN!,
});

Store a Single File

Uploads raw text to the configured R2 bucket and returns the generated key and public URL.

const embedData = {
  title: "Example",
  description: "Hello world"
};

const result = await sourceEmbed.store(
  JSON.stringify(embedData, null, 2)
);

console.log(result);

Example result:

{
  key: "550e8400-e29b-41d4-a716-446655440000.json",
  url: "https://raw.example.com/550e8400-e29b-41d4-a716-446655440000.json"
}

Store with Custom Extension

The file extension can be changed. Default extension is json.

await sourceEmbed.store("Hello world", "txt");

Example URL:

https://raw.example.com/<uuid>.txt

Store Multiple Files

Uploads multiple texts in parallel.

const contents = [
  JSON.stringify({ message: "one" }),
  JSON.stringify({ message: "two" }),
  JSON.stringify({ message: "three" })
];

const results = await sourceEmbed.storeMany(contents);

Example result:

[
  { status: "fulfilled", value: { key: "...", url: "..." } },
  { status: "fulfilled", value: { key: "...", url: "..." } },
  { status: "rejected", reason: Error }
]

Example Environment Variables

Store your Cloudflare R2 credentials as environment variables.

Example .env file:

R2_ACCESS_KEY_ID=your_access_key_id
R2_ACCESS_KEY_SECRET=your_secret_access_key
R2_ENDPOINT_URL=https://your-account-id.r2.cloudflarestorage.com
R2_BUCKET=your_bucket_name
R2_PUBLIC_DOMAIN=raw.example.com

License

MIT License