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

@idb-orm/react-query

v0.2.3

Published

An adapter for the Tanstack React-Query library for @idb-orm

Readme

@idb-orm/react-query

THIS PACKAGE IS BRAND-NEW AND UNSTABLE. DO NOT USE

A React adapter for Tanstack's Query library for @idb-orm. It essentially offers easy to use shortcuts to manage querying idb-orm data and caching. This package is an extension of @idb-orm/react.

Example

Here's an example comparison on how to do a find query on a users document collection in traditional Tanstack-query and with this package.

// How to do it in vanilla Tanstack-query
useQuery({
    queryKey: ["users", "find", userId],
    queryFn: () => client.stores.users.find({ where: { id: userId } }),
});

// How to do it in this package
stores.users.useFind({ where: { id: userId } });

// Or
stores.users.useFind({ where: { id: userId } }, [
    /* Any additional dependences */
]);

The package manages the internal query keys to ensure there is no overlap, and you can state an optional dependency array similar to traditional react hooks like useMemo and useEffect.

Installation

This package does not come bundled with Tanstack-query or react, they are both expected to already be installed. To install the adapter package, use:

npm i @idb-orm/react-query

Getting Started

Define your @idb-orm schema in any file. Then, call the factory function. This function will create a React Context, a Provider component for the context, and a series of hooks used to access the context's value.

// idb-query.ts

import { queryClientProviderFactory } from "@idb-orm/react-query";

// File that creates the @idb-orm database
import { db } from "./db";

export const {
    // Primitive React Context object
    Context,
    // Hook to acquire the IDB-ORM client object
    useDbClient,
    // Hook to acquire the Tanstack-Query QueryClient object
    useQueryClient,
    // Hook to acquire the auto-generated query functions.
    useQueryInterface,
    // Hook to acquire the contents of the 3 hooks above in one.
    useIDBQuery,
    // Provider that will allow the above hooks to function and populate the context.
    DbClientProvider,
} = queryClientProviderFactory(db);

Then, in your project's root, wrap your application in the provider:

// App.tsx

import { DbClientProvider } from "./idb-query";

function App(){
    return (
        <DbClientProvider version={2} fallback={<>Waiting for client creation...</>}>
            {/* Appliation */}
        <DbClientProvider>
    )
}

The fallback prop is an optional prop you can give to the provider to render while the client is building. Building the @idb-orm client is an asynchronous operation, so while that is being done its children are not rendered. This may be changed in a future update.

Usage

Anywhere inside a component, you can call one of three hooks for each store:

import { useQueryInterface } from "./idb-query";

function MyComponent(){
    const stores = useQueryInterface();

    // Will find all documents that matches the filter/selector
    stores.users.useFind({
        query: {
            /* Selector Object */
        },
        /* Additional options */
    });

    // Will find the first document that matches the filter/selector
    stores.users.useFindFirst({
        query: {
            /* Selector Object */
        },
        /* Additional options */
    });

    // Will find the first document that matches the filter/selector
    stores.users.useGet({
        key: /* Primary Key */
        /* Additional options */
    });

    return <>My Favorite Component</>
}

These hooks return the same type as the result of the Tanstack useQuery hook. Check out their documentation for more information as well as additional options.

Some things to note:

  • Fields passed into the query key of a hook input will be used to determine query invalidation. These query objects are serialized into JSON by Tanstack, so any TS/JS types that are not serializable into JSON (functions, files, undefined) will be omitted from the serialized representation. So if any of these types of values change, the query will NOT be automatically invalidated.
  • The DbClientProvider component already has the Tanstack QueryClientProvider included, you do not need to add another!

Disclaimer

This project is still in the very early stages. Bugs will occur as I work on this package. Sorry in advance.