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

vite-thumbhash

v0.1.0

Published

A Vite Plugin to generate thumbhash dataUrl at compile time.

Downloads

7

Readme

vite-thumbhash

A Vite Plugin to generate ThumbHash data URLs at compile time for your images.

ThumbHash generates compact image preview placeholders, similar to BlurHash but with smaller output size.

Features

  • 🚀 Generate ThumbHash data URLs during build time

  • 💾 Built-in caching for better performance

  • 🎯 TypeScript support

  • 📦 Makesure the aspect ratio of imgage.

    Use sharp.js to fix this issue Aspect ratio isn't the same · Issue #31 · evanw/thumbhash

  • 🖼️ Support multiple image formats (PNG, JPG, JPEG, WebP, AVIF, GIF)

Why ThumbHash?

  • Encodes more detail in the same space
  • Also encodes the aspect ratio
  • Gives more accurate colors
  • Supports images with alpha

Installation

npm install vite-thumbhash --save-dev
# or
yarn add vite-thumbhash -D
# or
pnpm add vite-thumbhash -D

Usage

1. Configure Vite Plugin

// vite.config.ts
import { defineConfig } from 'vite'
import thumbhash from 'vite-thumbhash'

export default defineConfig({
  plugins: [
    thumbhash({
      // optional configurations
      thumbhashOptions: {
        width: 40, // default: 40, max: 100
      },
      useCache: true, // default: true
    })
  ]
})

2. Import and Use (React)

// App.tsx
import { useState } from 'react'
import url from './assets/photo.jpg'
import thumbUrl from './assets/photo.jpg?thumb' // Import with ?thumb suffix

const ImageComponent = (props) => {
  const [loading, setLoading] = useState(false)
  
  useEffect(() => {
      const image = new Image()
      image.onload = () => {
          setLoading(false)
      };
      image.src = url
    }, [url])
  
  return (
    <div>
      <img width={'366px'} src={loading ? thumbUrl : url} />
    </div>
  )
}
export default ImageComponent

Configuration Options

interface IOptions {
  cacheDir?: string;       // Custom cache directory (relative to project root)
  cacheFile?: string;      // Custom cache filename (default: "thumbhash-cache.json")
  useCache?: boolean;      // Enable/disable caching (default: true)
  thumbhashOptions?: {
    width?: number;        // ThumbHash image width (default: 40, max: 100)
  };
}

Type Support

Types for importing images with ?thumb suffix are provided.

// vite-env.d.ts

/// <reference types="vite/client" />
/// <reference types="vite-thumbhash/types/images" />

License

MIT