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

thumbor-client

v0.4.1

Published

Thumbor URL builder for Node, Bun, Deno, edge runtimes and browsers

Readme

thumbor-client

URL builder for Thumbor. TypeScript, no dependencies, ~3 KB gzipped.

Documentation · Playground

Works in Node, Bun, Deno, Cloudflare Workers and browsers. Urls are built synchronously everywhere, signing included, so it works during SSR and in templates.

Install

npm i thumbor-client
# or
bun add thumbor-client
# or
deno add npm:thumbor-client

Usage

import { createThumbor } from 'thumbor-client'

const thumbor = createThumbor({
  url: 'https://thumbor.example.com',
  key: 'secret' // optional, omit for unsafe urls
})

thumbor.image('https://example.com/cat.jpg').resize(300, 200).smart().url()
// https://thumbor.example.com/gFMdxP8CRDmNv4bUKISOyjubGds=/300x200/smart/https://example.com/cat.jpg

Without key the url is unsafe:

https://thumbor.example.com/unsafe/300x200/smart/https://example.com/cat.jpg

Every call returns a new object, so a partly built image works as a preset:

const avatar = (src: string) => thumbor.image(src).resize(64, 64).smart()

avatar(user.photo).url()
avatar(user.photo).format('webp').url()

Fit-in, filters

thumbor.image('/photos/cat.jpg').fitIn(800, 600, { full: true }).quality(80).format('webp').url()
// https://thumbor.example.com/unsafe/full-fit-in/800x600/filters:quality(80):format(webp)/photos/cat.jpg

Crop and alignment

thumbor.image('/photos/cat.jpg').crop({ left: 10, top: 20, right: 410, bottom: 320 }).resize(200, 150).align('left', 'top').url()
// https://thumbor.example.com/unsafe/10x20:410x320/200x150/left/top/photos/cat.jpg

srcset

thumbor.image('cat.jpg').fitIn(800, 600).srcset([400, 800, 1200])
// .../fit-in/400x300/cat.jpg 400w, .../fit-in/800x600/cat.jpg 800w, .../fit-in/1200x900/cat.jpg 1200w

API

thumbor.image(src, { encode? }) returns an immutable image:

| Method | Thumbor segment | |---|---| | resize(width, height) | 300x200; 0 keeps proportions, 'orig' keeps the original size | | fitIn(width, height, { full?, adaptive? }) | fit-in, full-fit-in, adaptive-fit-in, adaptive-full-fit-in | | flip('horizontal' \| 'vertical' \| 'both') | -300x-200 | | crop({ left, top, right, bottom }) | 10x20:410x320 | | align(horizontal?, vertical?) | left/top | | smart() | smart | | trim(orientation?, tolerance?) | trim, trim:bottom-right:10 | | meta() | meta, JSON instead of the image | | debug() | debug, draws focal points | | quality(80), format('webp'), blur(5), ... | one method per Thumbor filter, see Filters | | filter(...calls) | any filter as a string | | url(), toString(), toJSON() | the url | | srcset(widths) | url 400w, url 800w |

The API from 0.3 and earlier (fromUrl, setPath, ..., buildURL()) still works and is deprecated. See Migrating.

Security key in the browser

The library can sign urls in the browser, but any key shipped to the browser is public. Sign on the server and pass ready urls to the client, or use unsafe urls with a Thumbor instance that allows them.

Browser without a bundler

ES module:

<script type="module">
  import { createThumbor } from 'https://cdn.jsdelivr.net/npm/thumbor-client/dist/thumbor-client.js'

  const url = createThumbor({ url: 'https://thumbor.example.com' })
    .image('https://example.com/cat.jpg')
    .resize(300, 200)
    .url()
</script>

Classic script, exposes the ThumborClient global:

<script src="https://cdn.jsdelivr.net/npm/thumbor-client/dist/thumbor-client.iife.js"></script>
<script>
  const url = ThumborClient.createThumbor({ url: 'https://thumbor.example.com' })
    .image('https://example.com/cat.jpg')
    .resize(300, 200)
    .url()
</script>

Pin at least the minor version in production: [email protected].

Development

Uses Bun locally. The published package does not depend on Bun.

bun install
bun run test         # unit tests (vitest)
bun run typecheck
bun run build        # dist/: esm, cjs, iife, d.ts
bun run test:smoke   # runs the built package in node (esm, cjs, iife)
bun run dev          # playground
bun run docs:dev     # docs site
bun run thumbor      # local thumbor on :8888, see compose.yaml
bun run test:live    # requests every url type from the local thumbor

CI also runs the smoke tests in Bun and Deno, and test:live against Thumbor 7.

License

MIT