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

glove-react

v2.0.5

Published

React bindings for Glove agent framework

Readme

glove-react

React bindings for the Glove agent framework — hooks, components, and tools with colocated renderers.

Install

npm install glove-react glove-next

Requires react >= 18.0.0 as a peer dependency.

Quick start

1. Server route (Next.js)

// app/api/chat/route.ts
import { createChatHandler } from "glove-next";

export const POST = createChatHandler({
  provider: "anthropic",
  model: "claude-sonnet-4-20250514",
});

2. Define tools

// lib/glove.tsx
import { GloveClient, defineTool } from "glove-react";
import type { ToolConfig } from "glove-react";
import { z } from "zod";

const inputSchema = z.object({
  question: z.string().describe("The question to display"),
  options: z.array(z.object({
    label: z.string().describe("Display text"),
    value: z.string().describe("Value returned when selected"),
  })),
});

const askPreferenceTool = defineTool({
  name: "ask_preference",
  description: "Present options for the user to choose from.",
  inputSchema,
  displayPropsSchema: inputSchema,     // optional, recommended for tools with UI
  resolveSchema: z.string(),
  displayStrategy: "hide-on-complete",
  async do(input, display) {
    const selected = await display.pushAndWait(input);
    return {
      status: "success" as const,
      data: `User selected: ${selected}`,
      renderData: { question: input.question, selected }, // client-only, not sent to AI
    };
  },
  render({ props, resolve }) {
    return (
      <div>
        <p>{props.question}</p>
        {props.options.map(opt => (
          <button key={opt.value} onClick={() => resolve(opt.value)}>
            {opt.label}
          </button>
        ))}
      </div>
    );
  },
  renderResult({ data }) {
    const { question, selected } = data as { question: string; selected: string };
    return <div><p>{question}</p><span>Selected: {selected}</span></div>;
  },
});

// Tools without display stay as raw ToolConfig
const getDateTool: ToolConfig = {
  name: "get_date",
  description: "Get today's date",
  inputSchema: z.object({}),
  async do() { return { status: "success", data: new Date().toLocaleDateString() }; },
};

export const gloveClient = new GloveClient({
  endpoint: "/api/chat",
  systemPrompt: "You are a helpful assistant.",
  tools: [askPreferenceTool, getDateTool],
});

3. Provider + UI

// app/providers.tsx
"use client";
import { GloveProvider } from "glove-react";
import { gloveClient } from "@/lib/glove";

export function Providers({ children }: { children: React.ReactNode }) {
  return <GloveProvider client={gloveClient}>{children}</GloveProvider>;
}
// app/page.tsx
"use client";
import { useGlove, Render } from "glove-react";

export default function Chat() {
  const glove = useGlove();

  return (
    <Render
      glove={glove}
      strategy="interleaved"
      renderMessage={({ entry }) => (
        <div><strong>{entry.kind === "user" ? "You" : "AI"}:</strong> {entry.text}</div>
      )}
      renderStreaming={({ text }) => <div style={{ opacity: 0.7 }}>{text}</div>}
    />
  );
}

Key exports

Components & hooks

  • GloveProvider — Context provider wrapping your app
  • useGlove(config?) — Main hook returning timeline, streamingText, busy, slots, tasks, stats, sendMessage, abort, renderSlot, renderToolResult, resolveSlot, rejectSlot
  • Render — Headless render component with automatic slot visibility, interleaving, and renderResult rendering

Tool helpers

  • defineTool(config) — Type-safe tool builder with colocated render and renderResult. Provides typed display props and resolve values.
  • ToolConfig — Raw tool interface for tools without display UI

Client

  • GloveClient — Configuration container. Pass endpoint (for server-side models via glove-next) or createModel (for client-side models).

Adapters

  • MemoryStore — In-memory store for prototyping
  • createRemoteStore — Delegates store operations to your API endpoints
  • createRemoteModel — Custom model adapter with prompt and optional promptStream
  • createEndpointModel — SSE-based model compatible with glove-next handlers
  • parseSSEStream — Parse an SSE response stream into RemoteStreamEvent objects

Voice bindings

Voice hooks and components are exported from glove-react/voice:

  • useGloveVoice — Core voice hook (mode, transcript, start/stop/interrupt)
  • useGlovePTT — Push-to-talk with click-vs-hold detection, hotkey, min-duration
  • VoicePTTButton — Headless PTT button with render prop and ARIA attributes

Requires glove-voice as a peer dependency.

Display strategies

| Strategy | Behavior | |----------|----------| | "stay" (default) | Slot always visible | | "hide-on-complete" | Hidden when slot is resolved/rejected | | "hide-on-new" | Hidden when a newer slot from the same tool appears |

Documentation

License

MIT