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

@avearra/hooks

v0.0.2

Published

Comprehensive collection of React hooks for AI, chat, UI, data management, and more

Readme

@avearra/hooks

A headless, provider-agnostic hooks suite for Agentic Chat UIs. Import from @avearra/hooks (or via avearra).

  • Categories: chat, ai, voice, data, streaming, media, storage, ui, a11y, state, utils
  • Design: Typed, SSR-safe, controlled/uncontrolled, composable.

Quick Start

import { useChat, useMessageComposer, useModel } from '@avearra/hooks';

Chat

useChat

Manages transcript, input, and attachments; sends one user message (text + attachments).

API

const chat = useChat({
  onSend: async (userMsg) => {/* return assistant message */},
  allowAttachmentsOnly: false,
});
// chat: { messages, input, setInput, attachments, addAttachments, removeAttachment, clearAttachments, send, clear, isEmpty }

Example

const chat = useChat({ allowAttachmentsOnly: true, onSend: async (u) => ({ id: crypto.randomUUID(), role: 'assistant', content: 'Echo: ' + (u.content || (u.attachments?.length ?? 0) + ' files'), createdAt: Date.now() }) });
<form onSubmit={(e)=>{e.preventDefault(); chat.send();}}>
  <input value={chat.input} onChange={(e)=>chat.setInput(e.target.value)} />
  <button type="submit">Send</button>
</form>

useMessageComposer

Headless input area controller for text + attachments, with validation.

const composer = useMessageComposer({ maxAttachments: 4, accept: ['image/', /pdf$/], maxSize: 5_000_000 });
// { text, setText, attachments, addFiles, removeAttachment, clearAttachments, readyToSend }

useChatHistory

Local storage sessions map: get/set/append/clear per session.

const hist = useChatHistory();
hist.append('session-1', ...messages);

useChatStreaming

Token streaming state for assistant responses.

const { start, stop, partial, status } = useChatStreaming();

AI

useModel

Provider-agnostic model caller; supports streaming via async generators.

const { callModel, running } = useModel(adapter);
const res = await callModel({ messages, stream: true, onToken: (t)=>setText(s=>s+t) });

useCompletion

Simple completion on top of useModel.

const { text, complete, running } = useCompletion(adapter);
await complete('Hello');

useToolCalls

Run model-requested tools deterministically.

const { run } = useToolCalls();
await run([{ name: 'search', args: { q: 'nx' } }], { search: async ({q})=>[] });

useRagQuery

Perform retrieval to augment prompts.

const { results, search } = useRagQuery(async (q)=>[{ id:'1', score:0.9, text:'...' }]);

useSafetyChecks

Compose moderation rules.

const { check } = useSafetyChecks([(p)=> p.content.includes('bad') ? { ok:false, reason:'policy' } : { ok:true }]);

Media and Input

useFileDropzone

const dz = useFileDropzone({ onFiles: addFiles, accept: ['image/'] });
<div {...dz.getRootProps()}>Drop files</div>

usePaste

const { onPaste } = usePaste({ onFiles: addFiles, onText: setText });
<div onPaste={onPaste} />

Clipboard

const { copy, copied } = useClipboard();

Streaming

  • useAbortableFetch: fetch + AbortController
  • useEventSource: SSE client
  • useReadableStream: read browser streams

Data

  • useQuery: minimal cached query with staleTime
  • useMutation: async mutation state
  • usePolling: interval polling

UI, A11y, State

  • useDisclosure, useOnClickOutside, useKeyboardShortcut, usePresence, useFocusTrap, useRovingFocus
  • useFocusRing, useLiveRegion
  • useDebouncedValue, useThrottledValue, useControllableState, useCounter
  • usePreferences, useLocalStorage, useSessionStorage
  • useId, useDimensions, useIntersection, useResizeObserver, useMediaQuery, useTimeout, useInterval

Recipe: Compose chat input

const chat = useChat({ onSend });
const composer = useMessageComposer({ maxAttachments: 4 });
const dropzone = useFileDropzone({ onFiles: composer.addFiles, accept: ['image/'] });
const paste = usePaste({ onFiles: composer.addFiles, onText: (t)=>chat.setInput(t) });

<form onSubmit={(e)=>{ e.preventDefault(); chat.setInput(composer.text); chat.addAttachments([]); chat.send(); composer.clearAttachments(); }} {...dropzone.getRootProps()} onPaste={paste.onPaste}>
  {/* render composer.attachments thumbnails */}
  <input value={chat.input} onChange={(e)=>chat.setInput(e.target.value)} />
</form>