DEV Community

Cover image for Preview npm packages from any PR
Torsten Dittmann
Torsten Dittmann

Posted on • Edited on

Preview npm packages from any PR

I recently launched pkg.vc to solve a problem that’s been a pain for years:

How do you test npm package changes from a PR or feature branch, without local builds or polluting the public registry with throwaway versions?

What is pkg.vc?

It’s a service that lets you:

  • Build and share installable npm packages from any branch or PR
  • Get a unique install URL for each commit, branch, or PR
  • Integrate with GitHub Actions or use it locally
  • Private packages

I was inspired by pkg.pr.new (which is great!), but I needed something that worked with private packages and works outside of GitHub Actions.

How it Works

1. Install the CLI:

npm install -g pkg.vc
# or just use npx
npx pkg.vc --organization my-org ./my-package
Enter fullscreen mode Exit fullscreen mode

You’ll need an API key (see the docs for setup).

2. Publish a Preview

After publishing, you get a unique install URL:

npm install https://pkg.vc/-/@my-org/my-package@5541c6f
Enter fullscreen mode Exit fullscreen mode

You can use this URL in any project to test the package - no need to publish to npm.

3. Automate with GitHub Actions

You can set up a workflow so every PR automatically publishes a preview package.

- uses: pkg-vc/publish-action@main
  with:
    organization: my-org
    directory: my-package
    secret: ${{ secrets.PKG_VC_SECRET }}
    github-token: ${{ secrets.GITHUB_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Now, every PR gets a comment with an install link.

pkg.vc pr comment

What’s Next?

I’m still iterating on this, and I’d love feedback.
If you’ve struggled with this workflow, or have ideas for improvement, let me know!

Top comments (0)