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

react-resource-ui

v0.1.5

Published

A high-level data orchestration hook for React with pagination, caching, and virtualization

Readme

React Resource UI

Headless pagination and list orchestration for React.
Switch between page, load more, and infinite scroll without rewriting UI logic.

npm: https://www.npmjs.com/package/react-resource-ui


Overview

React Resource UI is a headless abstraction for managing pagination behavior, list state, and virtualization in React applications.

Instead of rewriting logic when switching pagination patterns, you define your data source once and control behavior through configuration.


Why use this?

In real applications, pagination is more than just fetching data. You need to manage:

  • switching between page, load more, and infinite scroll
  • merging or replacing data correctly
  • handling race conditions and stale requests
  • keeping UI behavior consistent

Most tools provide low-level primitives, but you still write this logic yourself.

React Resource UI makes pagination behavior configuration-driven.


Headless by Design

This library does not enforce any UI or styling.

You can use it with:

  • custom components
  • Tailwind
  • Material UI
  • your own table or list implementations

The library handles state and behavior. You control rendering.


Installation

npm install react-resource-ui

Basic Usage

import { useResource } from "react-resource-ui";

function App() {
  const { data, loading, error, page, setPage, hasNext } = useResource({
    source: async ({ page = 1, pageSize = 10 }) => {
      const skip = (page - 1) * pageSize;

      const res = await fetch(
        `https://dummyjson.com/todos?limit=${pageSize}&skip=${skip}`
      );

      const json = await res.json();

      return {
        data: json.todos,
        total: json.total,
      };
    },

    pagination: {
      type: "page",
      pageSize: 10,
    },
  });

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

  return (
    <div>
      {data.map((item) => (
        <div key={item.id}>{item.todo}</div>
      ))}

      <button disabled={!hasNext} onClick={() => setPage((p) => p + 1)}>
        Next
      </button>
    </div>
  );
}

Pagination Modes

pagination: { type: "page" }
pagination: { type: "loadmore" }
pagination: { type: "infinite" }

Behavior

| Mode | Data Handling | |------------|----------------------| | page | replaces data | | loadmore | appends data | | infinite | auto fetch on scroll |

Switching modes does not require changing your data logic.


Source Contract

The source function receives:

{
  page?: number;
  pageSize?: number;
}

It must return either:

T[]

or

{
  data: T[],
  total: number
}

Returning { data, total } is recommended for accurate pagination.


Virtualization

virtualization: {
  enabled: true,
  itemHeight: 50,
  containerHeight: 300,
}

Virtualization renders only visible items for better performance on large datasets.


Using with DataTable (Optional)

import { useResource, DataTable } from "react-resource-ui";

The DataTable component is provided as a convenience.

You are free to build your own UI using the hook.


API (Summary)

useResource returns:

  • data
  • loading
  • error
  • page, setPage
  • hasNext
  • offsetY, totalHeight
  • scrollRef, setScrollTop

Documentation


When should you use this?

Use React Resource UI if you want to:

  • switch pagination types without rewriting logic
  • keep pagination behavior separate from UI
  • manage list state in a consistent way
  • add virtualization without another library

Status

Early release focused on the core pagination and virtualization engine.


Roadmap

  • Grid-based rendering for virtualization
  • Sorting and filtering
  • Form integration
  • improved caching strategies

Author

Kalyan Mantha