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

@hecto/query

v1.1.0

Published

Typed async query cache with stale data, optimistic mutations, and hydration.

Readme

@hecto/query

Typed, framework-neutral fetch caching built on cancellable Tasks. Use it when a value is opaque to the client: a profile, search result, dashboard tile, or paged HTTP response.

import { createQueryClient, defineQuery } from '@hecto/query'

const client = createQueryClient()
const user = defineQuery({
  key: (id: number) => ['user', id] as const,
  fetch: async ({ params, signal }) =>
    fetch(`/api/users/${params[0]}`, { signal }).then((response) => response.json()),
  options: { staleTime: 30_000, retry: 2, backoff: 'exponential' },
})

await client.fetch(user, 42)
client.invalidate(['user'])

defineQuery keeps keys and parameters typed. Entries deduplicate concurrent fetches, retain stale values while refetching, use one focus/online listener per client, and support cancellation, prefix invalidation, prefetching, infinite pages, hydrated cache state, and serial or offline-paused mutations. entry.fetch({ force: true }) bypasses freshness checks but still joins active work. Add replace: true only when the active operation must be cancelled and replaced. Infinite refetches retain the first stored cursor and recompute each following cursor from the newly fetched page, so changed server pagination stays valid. Every mutateAsync call owns its completion, including while offline or queued behind the same mutation scope. Resume settles that original promise; reset or client disposal rejects it with CancelledError. Mutation retry counts additional attempts and supports retryDelay plus an injected scheduler; terminal callbacks run once after attempts finish.

Query keys support strings, booleans, finite numbers, null, arrays, and plain records. Record keys are sorted, undefined record properties are omitted, and undefined array items match null, following JSON normalization. Cycles, dates, functions, symbols, bigints, maps, sets, class instances, and non-finite numbers throw a TypeError.

How it differs from TanStack Query

  • Query keys are typed tuples, not API-level hashes.
  • Fetchers can return Task<Result<T, E>>, so expected typed failures do not need to become exceptions.
  • Query values stay opaque. Identity, patches, optimistic rows, and live joins belong in @hecto/db.
  • It has no streamed SSR or cross-tab broadcast layer yet; add either only when this workspace has a concrete host for it.

Use framework bindings from @hecto/query/react, /vue, /solid, /svelte, or /angular.

Native View ownership

@hecto/query/view is optional; the neutral Query entry does not import View. Create the client at the request or application lifetime, then bind an observer inside a View owner:

import { useQuery } from '@hecto/query/view'
const user = useQuery(client, userById, () => [selectedId.get()], {
  select: value => value.name,
})
// In a native binding: user.state().data, .status, .fetchStatus or .error.
// A user action can await user.refetch().

The tuple accessor tracks parameter changes. A null query key skips observation and refetch. The binding releases its own observer when its owner ends; it does not destroy the client or cancel another consumer's request. destroy() provides earlier explicit release.

Seed a request-owned client before SSR and hydrate the application client from that snapshot before attachment. client.getState(definition, ...params) reads an existing cache entry without creating one. Server bindings read this snapshot without observing, pinning, fetching or scheduling timers; missing queries render idle (or definition initial/placeholder data). Client observation begins on mount. Server refetch() is inert: fetch data before entering the render scope.