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

react-litert-lm

v2.1.0

Published

[![npm](https://img.shields.io/npm/v/react-litert-lm?color=brightgreen&label=npm)](https://www.npmjs.com/package/react-litert-lm) [![docs](https://img.shields.io/badge/docs-live-blue?logo=read-the-docs)](https://sanjaiyan-dev.github.io/react-litert-lm/) [

Readme

react-litert-lm

npm docs license

A lightweight React integration layer for @litert-lm/core, crafted for elegant conversational UI workflows.

react-litert-lm gives you:

  • A React provider that bootstraps a LiteRt engine cleanly
  • Hook-driven chat flows for both non-streaming and streaming use cases
  • Optional TanStack Query adapters for cache-aware and query-driven chat
  • Minimal API surface with strong TypeScript support

🚀 Why this package

react-litert-lm is built to help React teams ship modern chat experiences with clarity and composability.

  • Clean separation between engine setup and conversation behavior
  • Streaming-ready response handling with incremental text rendering
  • Optional query orchestration via @tanstack/react-query
  • Designed for React 19 and @litert-lm/core

📦 Installation

npm install react-litert-lm

Peer dependencies: react, @litert-lm/core. @tanstack/react-query is optional and only required for the TanStack integrations.


✨ Quick start

Use LiteRtEngineProvider to wrap your app and initialize the engine once.

import { LiteRtEngineProvider, useLiteRtChatNonStream } from "react-litert-lm";

function Chat() {
  const { result, sendMessage, cancelMessage, isPending } = useLiteRtChatNonStream({
    preface: "You are an assistant that answers clearly.",
  });

  return (
    <div>
      <button onClick={() => sendMessage({ content: "Hello" })}>Send</button>
      {isPending && <span>Loading…</span>}
      {result && <p>{result.content}</p>}
      <button onClick={cancelMessage}>Cancel</button>
    </div>
  );
}

export default function App() {
  return (
    <LiteRtEngineProvider model="gpt-4" backend="openai">
      <Chat />
    </LiteRtEngineProvider>
  );
}

🔥 Streaming chat

Stream messages in real time and render partial responses as they arrive.

import { useLiteRtChatStream } from "react-litert-lm";

function StreamingChat() {
  const { streamingText, sendMessage, isStreaming, cancelMessage, error } =
    useLiteRtChatStream({ preface: "You are a streaming assistant." });

  return (
    <div>
      <button onClick={() => sendMessage({ content: "Tell me a short story." })}>
        Start
      </button>
      {isStreaming ? <p>Streaming…</p> : <p>{streamingText}</p>}
      {error && <p style={{ color: "red" }}>{error.message}</p>}
      <button onClick={cancelMessage}>Cancel</button>
    </div>
  );
}

⚡ TanStack Query integration

Use TanStack React Query adapters for cache-backed chat requests and predictable network behavior.

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { LiteRtEngineProvider } from "react-litert-lm";
import { useLiteRtChatNonStreamTanstackQuery } from "react-litert-lm/tanstack";

const queryClient = new QueryClient();

function QueryChat({ message }: { message: string }) {
  const { data, isFetching } = useLiteRtChatNonStreamTanstackQuery({
    message: { content: message },
    preface: "Answer in one sentence.",
  });

  return <div>{isFetching ? <span>Loading…</span> : <p>{data?.content}</p>}</div>;
}

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <LiteRtEngineProvider model="gpt-4" backend="openai">
        <QueryChat message="What is React?" />
      </LiteRtEngineProvider>
    </QueryClientProvider>
  );
}

📚 Exposed API

LiteRtEngineProvider

Initializes a memoized @litert-lm/core engine and exposes it through React context.

useLiteRtEngine

Returns the engine instance created from provider settings.

useLiteRtChatConversationInit

Creates a conversation instance with optional session configuration and preface.

useLiteRtChatNonStream

Simple non-streaming chat hook with cancellation support.

useLiteRtChatStream

Streaming chat hook that exposes incremental response text, loading state, and errors.

useLiteRtChatNonStreamTanstackQuery

TanStack Query hook for non-streaming chat with caching and query lifecycle control.

useLiteRtChatStreamTanstackQuery

Stream-aware query hook built around experimental_streamedQuery.


🛠️ Scripts

npm run build
npm run format
npm run lint
npm run docs
npm run deploy

💡 Contribution guidelines

  • Keep APIs minimal and composable
  • Maintain strong TypeScript type safety
  • Prefer React-friendly hooks and declarative patterns
  • Use tsup for builds and typedoc for docs generation

📄 License

Released under the ISC license.