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

reactive-query-react

v0.0.1

Published

This is a React adapter library for [reactive-query](https://github.com/behnamrhp/reactive-query), providing seamless integration between reactive query models and React components.

Readme

Reactive Query React Adapter

This is a React adapter library for reactive-query, providing seamless integration between reactive query models and React components.

Installation

npm install reactive-query-react
# or
yarn add reactive-query-react

Peer Dependencies

This library requires the following peer dependencies:

  • react (^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0)
  • rxjs (^7.8.0)
  • reactive-query (^0.2.7)

Usage

Basic Usage

import React from 'react';
import { useRXQuery } from 'reactive-query-react';
import { yourQueryModel } from './your-query-model';

function MyComponent() {
  const queryData = useRXQuery(yourQueryModel.query);

  if (queryData.loading) {
    return <div>Loading...</div>;
  }

  if (queryData.error) {
    return <div>Error: {queryData.error.message}</div>;
  }

  return <div>Data: {JSON.stringify(queryData.data)}</div>;
}

With Configuration

import React from 'react';
import { useRXQuery } from 'reactive-query-react';
import { userQueryModel } from './user-query-model';

function UserProfile({ userId }: { userId: string }) {
  const userData = useRXQuery(
    userQueryModel.getUser,
    {
      initialState: { name: 'Loading...', email: '' },
      keysToRecallQuery: [userId] // Re-query when userId changes
    }
  );

  return (
    <div>
      <h2>{userData.data?.name}</h2>
      <p>{userData.data?.email}</p>
      {userData.loading && <span>Loading...</span>}
    </div>
  );
}

API Reference

useRXQuery<T>

A React hook that converts observable query model data to React state, bridging the push strategy of RxJS to the pull strategy of React.

Parameters

  • query: A function that returns an Observable of QueryResponse or undefined
  • configs: Optional configuration object

Configuration Options

  • initialState: Initial data state before the query loads
  • keysToRecallQuery: Array of values that trigger re-querying when changed

Returns

Returns a QueryResponse object with the following properties:

  • data: The query result data
  • loading: Boolean indicating if the query is in progress
  • error: Error object if the query failed
  • success: Boolean indicating if the query completed successfully

How It Works

The useRXQuery hook:

  1. Subscribes to the observable returned by your query function
  2. Manages React state for loading, error, and data states
  3. Automatically unsubscribes when the component unmounts
  4. Re-queries when specified keys change
  5. Handles the conversion from RxJS observables to React state

Examples

Conditional Queries

function ConditionalQuery({ shouldFetch, id }: { shouldFetch: boolean; id: string }) {
  const data = useRXQuery(
    shouldFetch ? () => queryModel.getData(id) : undefined
  );
  
  // When shouldFetch is false, returns initial state
  return <div>{data.data ? 'Has data' : 'No data'}</div>;
}

Dynamic Queries

function DynamicQuery({ filters }: { filters: Record<string, any> }) {
  const data = useRXQuery(
    queryModel.getFilteredData,
    {
      keysToRecallQuery: [JSON.stringify(filters)] // Re-query when filters change
    }
  );
  
  return <div>{/* render data */}</div>;
}

Contributing

This library is part of the reactive-query project. Please refer to the main repository for contribution guidelines.

License

MIT License - see the main reactive-query repository for details.