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

webgpu-gemma

v0.1.0

Published

Browser-native, WebGPU-accelerated Gemma inference. Tiny SDK + React hook, zero server.

Readme

@bilkobibitkov/webgpu-gemma

Browser-native, WebGPU-accelerated Gemma inference. Tiny SDK (≤45 KB gz) + React hook, zero server.

Documents and text never leave the device. The model runs in the browser tab via WebGPU.

Requirements

  • Chrome ≥ 113 or Edge ≥ 113 (desktop)
  • A GPU with WebGPU support

Safari < 18 and all mobile browsers are not supported.

Install

pnpm add @bilkobibitkov/webgpu-gemma
# react subpath requires react ≥ 18

Usage

Core (framework-agnostic)

import { GemmaSession, isWebGPUAvailable } from '@bilkobibitkov/webgpu-gemma';
import { MODELS } from './models'; // see MODELS.md

if (!isWebGPUAvailable()) {
  console.error('WebGPU not available');
} else {
  const session = await GemmaSession.load({
    modelUrl: 'gemma-2-2b-it-q4f16_1-MLC', // see MODELS.md
    quantization: 'q4_k_m',
    contextLength: 4096,
    onProgress: (loaded, total) => console.log(`${loaded}/${total}`),
  });

  // Streaming generation
  for await (const token of session.generate('Summarize this text: ...', { maxTokens: 512 })) {
    process.stdout.write(token);
  }

  // Embeddings (where supported by model)
  const vec = await session.embed('Hello world');

  session.dispose();
}

React hook

import { useGemma } from '@bilkobibitkov/webgpu-gemma/react';
import { useState } from 'react';

function App() {
  const [started, setStarted] = useState(false);

  const { session, loading, error, progress } = useGemma(
    started
      ? { modelUrl: 'gemma-2-2b-it-q4f16_1-MLC', quantization: 'q4_k_m', contextLength: 4096 }
      : null,
  );

  if (loading) return <p>Loading model… {Math.round(progress * 100)}%</p>;
  if (error) return <p>Error: {error.message}</p>;

  return (
    <div>
      {!started && <button onClick={() => setStarted(true)}>Load Gemma</button>}
      {session && <YourInferenceUI session={session} />}
    </div>
  );
}

API

isWebGPUAvailable(): boolean

Returns true when navigator.gpu is present. Call this before rendering any load UI.

GemmaSession.load(config): Promise<GemmaSession>

Downloads and initialises the model. Throws WebGPUUnavailableError when WebGPU is absent.

| Field | Type | Description | |---|---|---| | modelUrl | string | web-llm model ID or HF URL — see MODELS.md | | quantization | 'q4_0' \| 'q4_k_m' \| 'fp16' | Must match the model | | contextLength | number | Token context window (e.g. 4096) | | onProgress | (loaded, total) => void | Called with 0–100 progress integers |

session.generate(prompt, opts?): AsyncIterable<string>

Streams tokens. Opts: maxTokens (default 2048), temperature (default 0.7), stop.

session.embed(text): Promise<Float32Array>

Returns a dense embedding vector. Not all models support this; throws if unsupported.

session.dispose(): void

Releases GPU memory. Always call when done.

useGemma(config | null): { session, loading, error, progress }

React hook. Pass null to skip loading. Config changes (by value) restart the session automatically.

Supported models

See MODELS.md for the three recommended model IDs and their HuggingFace sources.

License notice

This SDK is MIT licensed. However, the Gemma model weights you load at runtime are subject to Google's Gemma Terms of Use. By using this library to load Gemma weights, you agree to abide by that license. The weights are not bundled in this package — they are downloaded from HuggingFace at runtime.