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

@localmode/react

v2.0.0

Published

React hooks for @localmode — useChat, useEmbed, useClassify, and more

Readme

@localmode/react

npm license

Docs Demo

React hooks for local-first AI. Embed, chat, classify, transcribe, and more — with built-in loading states, error handling, and cancellation.

Installation

pnpm install @localmode/react @localmode/core

Quick Start

import { useChat } from '@localmode/react';
import { webllm } from '@localmode/webllm';

const model = webllm.languageModel('Llama-3.2-1B-Instruct-q4f16_1-MLC');

function Chat() {
  const { messages, isStreaming, send, cancel } = useChat({ model });

  return (
    <div>
      {messages.map((m) => (
        <div key={m.id}><b>{m.role}:</b> {m.content}</div>
      ))}
      <button onClick={() => send('What is LocalMode?')}>Send</button>
      {isStreaming && <button onClick={cancel}>Stop</button>}
    </div>
  );
}

Domain Hooks

| Hook | Domain | Wraps | |------|--------|-------| | useEmbed | Embeddings | embed() | | useEmbedMany | Embeddings | embedMany() | | useSemanticSearch | Embeddings | semanticSearch() | | useEmbedImage | Multimodal | embedImage() — CLIP cross-modal | | useEmbedManyImages | Multimodal | embedManyImages() — batch image embedding | | useChat | Generation | streamText() with message state, vision image support | | useGenerateText | Generation | generateText() | | useGenerateObject | Generation | generateObject() — typed JSON output | | useClassify | Classification | classify() | | useClassifyZeroShot | Classification | classifyZeroShot() | | useExtractEntities | NER | extractEntities() | | useTranscribe | Audio | transcribe() | | useSynthesizeSpeech | Audio | synthesizeSpeech() | | useCaptionImage | Vision | captionImage() | | useDetectObjects | Vision | detectObjects() | | useClassifyImage | Vision | classifyImage() | | useClassifyImageZeroShot | Vision | classifyImageZeroShot() | | useSegmentImage | Vision | segmentImage() | | useExtractImageFeatures | Vision | extractImageFeatures() | | useImageToImage | Vision | imageToImage() | | useTranslate | Text | translate() | | useSummarize | Text | summarize() | | useExtractText | OCR | extractText() | | useFillMask | NLP | fillMask() | | useAnswerQuestion | QA | answerQuestion() | | useAskDocument | Document QA | askDocument() | | useAgent | Agents | createAgent() + runAgent() — ReAct loop with tools | | useImportExport | Import/Export | importFrom(), exportToCSV(), exportToJSONL() | | useEvaluateModel | Evaluation | evaluateModel() — run metrics against a dataset | | useSemanticChunk | RAG | semanticChunk() — embedding-aware topic-boundary chunking | | useCalibrateThreshold | Embeddings | calibrateThreshold() — empirical similarity threshold |

Utility Hooks

| Hook | Purpose | |------|---------| | useModelStatus | Track model readiness | | useCapabilities | Detect browser AI capabilities | | useNetworkStatus | Online/offline status | | useStorageQuota | Storage quota monitoring | | useVoiceRecorder | MediaRecorder lifecycle (start/stop recording) | | useInferenceQueue | Priority-based task scheduling with live stats | | useSemanticCache | Semantic cache lifecycle (create/destroy, stats) | | useReindex | Embedding drift re-embedding with progress and cancellation | | useModelRecommendations | Ranked model recommendations by device capabilities | | useAdaptiveBatchSize | Device-aware optimal batch size for embeddings/inference |

Batch & List Processing

| Hook | Purpose | |------|---------| | useBatchOperation | Concurrent batch with progress | | useOperationList | Accumulate results into a list with item removal | | useSequentialBatch | Sequential processing with progress | | usePipeline | Multi-step workflows with progress |

Helper Utilities

| Utility | Purpose | |---------|---------| | readFileAsDataUrl(file) | Read a File as a data URL string | | validateFile({ file, accept, maxSize }) | Validate file type/size, returns AppError \| null | | downloadBlob(content, filename, mimeType?) | Trigger file download from in-memory content | | toAppError(error, recoverable?) | Convert Error to AppError shape |

Features

  • 35 domain hooks — One for each AI capability in @localmode/core (including agents, import/export, evaluation, semantic chunking, threshold calibration)
  • 10 utility hooks — Model status, capabilities, network, storage, voice recording, inference queue, semantic cache, reindex, model recommendations, adaptive batch size
  • 4 batch/pipeline hooks — List accumulation, concurrent batch, sequential batch, pipeline
  • 9 pipeline step factories — embedStep, chunkStep, searchStep, rerankStep, storeStep, classifyStep, summarizeStep, generateStep, embedManyStep
  • 4 helper utilities — File reading, validation, download, error conversion
  • Zero dependencies — only peer deps on react and @localmode/core
  • StreaminguseChat with real-time message updates and IndexedDB persistence
  • Cancellation — every hook supports AbortSignal-based cancellation
  • SSR-safe — no-op during server rendering for Next.js compatibility
  • Provider-agnostic — works with any @localmode provider

Documentation

localmode.dev/docs/react

License

MIT