Skip to content

Instantly share code, notes, and snippets.

@AmirSa12
Last active May 17, 2025 16:51
Show Gist options
  • Save AmirSa12/2eed810c8d30ed0dc51eda22acebc3e2 to your computer and use it in GitHub Desktop.
Save AmirSa12/2eed810c8d30ed0dc51eda22acebc3e2 to your computer and use it in GitHub Desktop.

Cloudflare is now the hosting partner of pkg.pr.new!

pkg.pr.new, is a tool that changes how developers access and test unreleased package features. At its core, pkg.pr.new automatically generates preview releases for each commit and pull request in your repository without publishing anything to npm!

The concept is simple and powerful at the same time: whenever a commit is pushed or a pull request is created, pkg.pr.new creates an instantly usable version of the package that can be installed directly from a unique npm compatible URL. This allows users and contributors to test new features or bug fixes without waiting for the official release cycle or even having access to npm publishing rights :D

A typical installation command looks like this:

npm i https://pkg.pr.new/vite@main

In the above command, main refers to the latest commit on the main branch of the vite repository.

How pkg.pr.new Helps Users

pkg.pr.new solves several pain points in development workflows by making package previews immediate, accessible, and easy!

Take the common frustration of waiting on a release for a bug fix that’s already been merged. With pkg.pr.new, there’s no need to ask, “Can we release that fix?” Users can install the exact commit with the fix right away, getting ahead of the release cycle entirely.

Contributors also benefit from a simpler testing process. They can share links to preview builds directly in pull requests, making it easier for collaborators to test changes before merging, in other words, a faster path to getting feedback!

Another advantage is that contributors don’t need npm publishing access. Anyone with GitHub commit access can generate a usable version of the package automatically.

pkg.pr.new can be easily used in GitHub workflows. With minimal setup — just install the GitHub app and add a simple workflow command, preview packages are generated automatically with every commit and pull request.

It supports template-powered interactive Stackblitz demos. Users can try what the developers has releases in a completely sandboxed and isolated environment called the webcontainers.

Current Usage

Thanks to the users, the adoption of pkg.pr.new has been amazing! With impressive usage statistics showing its value to the JavaScript ecosystem. At the time of writing this post:

  • 1,132,793 templates generated: Developers are actively using interactive demos to showcase their packages
  • 1,339,390 packages released: Over a million preview packages have been released through the platform
  • 614 organizations have integrated pkg.pr.new into their workflows
  • 1,103 repositories are actively using the tool
  • 1,339,390 commits have triggered preview package builds
  • 45,098 PRs and branches have been associated with preview packages

Many projects and companies are using pkg.pr.new, including Meta, Hugging Face, Vite, Svelte, Nuxt, Vue.js, Vitest, Qwik, TanStack, tRPC, and many others.

How We Use Cloudflare R2

A critical component of pkg.pr.new's architecture is Cloudflare R2, which provides the storage backbone for the service. R2 has been essential in making pkg.pr.new both performant and cost-effective.

Efficient Package Storage

Each preview package generated by pkg.pr.new is stored in R2 buckets. The system uses two separate buckets - a production bucket (PROD_CR_BUCKET) and a development/staging bucket (CR_BUCKET). This separation allows for a better testing and development without affecting production packages.

Storage Management

We implemented a storage management system that monitors package usage patterns. Packages that haven't been downloaded in over a month and are at least one month old are automatically removed, while any package older than six months is removed regardless of download activity. This cleanup mechanism keeps storage costs manageable while ensuring packages remain available when needed. By automatically removing unused or old builds, pkg.pr.new stays true to its purpose: providing temporary, on-demand preview releases rather than serving as a permanent package registry :)

Stream-Based Package Delivery

When a user installs a preview, it’s streamed directly from R2. This reduces memory overhead and ensures fast delivery, even for large packages.

Multipart Upload Support

For larger packages, pkg.pr.new utilizes R2's multipart upload functionality, allowing the system to handle packages of any size efficiently by splitting them into manageable chunks during the upload process.

Final Words

pkg.pr.new is maintained by the StackBlitz-labs team, with development led by Mohammad and Amir (Thundraa is what we call ourselves).

Huge thanks to Cloudflare for powering our storage infrastructure and helping us scale sustainably.

Special thanks to Matias Capeletto for helping us make pkg.pr.new a better, more robust tool. Your ideas and support have made a big difference.

And shoutout to Dario Piotrowicz for making the Cloudflare partnership possible in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment