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

@think-grid-labs/snapbolt

v0.1.7

Published

Unified image optimization toolkit for the browser and React

Readme

@think-grid-labs/snapbolt

A high-performance image optimization toolkit powered by Rust and WebAssembly.

Overview

This toolkit provides professional-grade image optimization (resizing and JPEG/WebP encoding) that runs entirely on the client side. No server costs, no API keys.

Quick Start

1. Install

npm install @think-grid-labs/snapbolt

2. Setup WASM

You need to make the .wasm file available to your browser. Option A: Automatic (CLI)

npx @think-grid-labs/snapbolt-cli sync ./public

Option B: Manual Copy node_modules/@think-grid-labs/snapbolt/pkg/snapbolt_bg.wasm to your public folder.

3. Usage

import { useImageOptimizer } from '@think-grid-labs/snapbolt';

const SmartImage = ({ src }) => {
  const { optimizedUrl, loading, error } = useImageOptimizer(src, {
    quality: 80,
    width: 1920, // Check "Memory Safety" below
    cache: true,
  });

  if (loading) return <div className="skeleton" />;
  if (error) return <img src={src} />; // Fallback to original

  return <img src={optimizedUrl || src} alt="Optimized" />;
};

Advanced Configuration

1. Cross-Origin Images (S3 / CDN)

Problem: Browsers block fetch() on cross-origin images by default (CORS). Solution:

  1. Configure S3/CDN: Add Access-Control-Allow-Origin: * header to your bucket.
  2. Enable in Snapbolt:
    useImageOptimizer(imageUrl, { crossOrigin: 'anonymous' })

2. WASM Loading & Bundlers

If your bundler (Vite, Next.js, Webpack) struggles to find the WASM file, you can explicitly tell Snapbolt where to find it.

useImageOptimizer(src, { 
    wasmUrl: '/snapbolt_bg.wasm' // Path to file in public/ folder
})

Next.js Integration

If you see Module not found errors, you need to transpile the package.

  1. Update next.config.js or next.config.ts:
    const nextConfig = {
      transpilePackages: ['@think-grid-labs/snapbolt'],
      // ...
    }
  2. Sync WASM to Public: Run this command to copy the WASM file to your public folder so the browser can load it:
    npx @think-grid-labs/snapbolt-cli sync ./public

3. Memory Safety (Large Images)

Optimizing 4K/8K images in WASM can crash mobile browsers due to memory limits. Best Practice: Always provide a width or height to downscale the image before processing.

useImageOptimizer(src, { 
    width: 1200, // Resize to 1200px width (auto height) BEFORE optimizing
})

4. Caching

Snapbolt automatically caches optimized results in the browser's Cache API (snapbolt-v1).

  • Enabled by default.
  • To disable: useImageOptimizer(src, { cache: false })

5. Supported File Types

Core supports: JPEG, JPG, PNG, WebP.

  • Unsupported types (GIF, SVG, TIFF) are automatically detected and skipped (returns original URL).

Troubleshooting

1. Image not optimizing (Returns original URL)

  • Check Console: Look for "Snapbolt: Unsupported Content-Type" warnings.
  • CORS: If using an external CDN (S3, Cloudinary), ensure it returns Access-Control-Allow-Origin: * or your domain. Use { crossOrigin: 'anonymous' }.

2. "Module not found" in Next.js

  • Ensure @think-grid-labs/snapbolt is in transpilePackages in next.config.js.
  • If using pnpm workspaces, ensure the package is correctly linked or installed.

3. "RuntimeError: memory access out of bounds"

  • The image is too large for the WASM memory buffer.
  • Fix: Use the width or height prop to downscale the image using the Canvas API before sending it to WASM.

Features

  • Client-Side Optimization: Zero server cost.
  • Blazing Fast: Powered by a Rust core.
  • Memory Safe: Smart pre-resizing.
  • React Ready: Easy-to-use hooks.

For full documentation, visit our GitHub Repository.