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

@jamestalmage/lit-query

v0.1.0

Published

Lit adapter for TanStack Query Core

Downloads

83

Readme

@tanstack/lit-query

Lit adapter for @tanstack/query-core using Lit reactive controllers.

Install

npm install @tanstack/lit-query @tanstack/query-core lit @lit/context

For local development in this repository:

npm install
npm run build

Quick Start

import { LitElement, html } from 'lit'
import { QueryClient } from '@tanstack/query-core'
import { QueryClientProvider, createQueryController } from '@tanstack/lit-query'

const client = new QueryClient({
  defaultOptions: { queries: { retry: false } },
})

class AppProvider extends QueryClientProvider {
  constructor() {
    super()
    this.client = client
  }

  protected override createRenderRoot(): HTMLElement | DocumentFragment {
    return this
  }
}
customElements.define('app-provider', AppProvider)

class UsersView extends LitElement {
  private readonly users = createQueryController(this, {
    queryKey: ['users'],
    queryFn: async () => {
      const response = await fetch('/api/users')
      return response.json() as Promise<Array<{ id: string; name: string }>>
    },
  })

  protected override createRenderRoot(): HTMLElement | DocumentFragment {
    return this
  }

  render() {
    const query = this.users()
    if (query.isPending) return html`Loading...`
    if (query.isError) return html`Error`
    return html`<ul>
      ${query.data?.map((u) => html`<li>${u.name}</li>`)}
    </ul>`
  }
}
customElements.define('users-view', UsersView)

API Surface (v1)

  • QueryClientProvider, useQueryClient, resolveQueryClient
  • createQueryController
  • createMutationController
  • createInfiniteQueryController
  • createQueriesController
  • useIsFetching, useIsMutating, useMutationState
  • queryOptions, infiniteQueryOptions, mutationOptions

Runnable Examples

This repo includes a Vite Lit example app at examples/lit-query-e2e-app. The demo uses a local in-memory mock API (src/todoApi.ts) for deterministic behavior.

Run:

npm run example:install
npm run example:dev

Open:

  • http://127.0.0.1:4173/ (full integration demo)
  • http://127.0.0.1:4173/basic-query.html (query-only runnable example)
  • http://127.0.0.1:4173/mutation.html (mutation runnable example)

Smoke test:

npm run example:e2e

Focused scenarios:

npm run example:e2e:query-error
npm run example:e2e:mutation-error
npm run example:e2e:refetch-button
npm run example:e2e:lifecycle-reconnect
npm run example:e2e:lifecycle-contract

Run all scenarios:

npm run example:e2e:all

This repo also includes a pagination example app at examples/lit-query-pagination-app. It demonstrates paginated queries, optimistic updates, prefetching, and error recovery against a local API.

Run:

npm run example:pagination:install
npm run example:pagination:dev

Smoke test:

npm run example:pagination:e2e

Focused scenarios:

npm run example:pagination:e2e:prefetch
npm run example:pagination:e2e:error
npm run example:pagination:e2e:mutations
npm run example:pagination:e2e:boundary

Run all scenarios:

npm run example:pagination:e2e:all

Use a different port (optional):

DEMO_PORT=4180 npm run example:dev
DEMO_PORT=4180 npm run example:e2e:all

E2E harness options (optional):

PW_HTTP_PROBE_TIMEOUT_MS=1000
PW_SERVER_READY_TIMEOUT_MS=30000
PW_WAIT_FOR_TEXT_TIMEOUT_MS=10000
PW_CAPTURE_FAILURE_ARTIFACTS=false
PW_ARTIFACT_DIR=output/playwright

This repo also includes an SSR example app at examples/lit-query-ssr-app. It demonstrates explicit QueryClient prefetch, SSR render, dehydrate, and hydrate flow for Lit.

Run:

npm run example:ssr:install
npm run example:ssr:dev

Open:

  • http://127.0.0.1:4174/ (SSR example app)

Smoke test:

npm run example:ssr:e2e

That root smoke test runs both the default same-origin SSR flow and the documented SSR_PUBLIC_ORIGIN=http://localhost:4174 variant.

Focused scenarios:

npm run example:ssr:e2e:error
npm run example:ssr:e2e:refreshing

Run the full default-origin SSR suite plus the documented public-origin smoke:

npm run example:ssr:e2e:all

Run either path directly (optional):

npm run example:ssr:e2e:default
npm run example:ssr:e2e:public-origin
npm run example:ssr:e2e:all:default

Use a different host or port (optional):

SSR_PORT=4180 npm run example:ssr:dev
SSR_PORT=4180 npm run example:ssr:e2e
SSR_HOST=0.0.0.0 npm run example:ssr:dev
npm run example:ssr:dev:public-origin

Quality Gates

  • Core matrix: docs/TEST_MATRIX.md
  • Integration matrix: docs/TEST_MATRIX_INTEGRATION.md
  • Perf matrix: docs/TEST_MATRIX_PERF.md
  • RFC and phase log: docs/RFC-v4.1.md

Current local quality gate:

npm run test:types && npm run test:lib && npm run build && npm run test:build

License

MIT