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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-carousel-query

v3.1.0

Published

A infinite carousel component made with react that handles the pagination for you.

Readme

react-carousel-query

NPM

TypeScript

| Statements | Branches | Functions | Lines | | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | Statements | Branches | Functions | Lines |

  • Lightweight React component with minimal footprint
  • Infinite carousel with automatic pagination management
  • Fetches data on demand as users navigate through slides
  • Zero external dependencies (only React and classnames)
  • Fully customizable slide, arrow, and badge rendering
  • Optimized for performance
  • Touch and mouse swipe support for mobile and desktop
  • TypeScript declarations included

Working demo here

Screenshot

Installation

Requirements: React 16.8.0 or higher

npm install react-carousel-query

Props

| Prop | Type | Default | Description | | ------------- | ---------- | ------------ | -------------------------------------------------------------------------------------------------------------------------- | | renderItem | function | required | Render function for each slide. Receives { item } as argument. You can render just an img or any other React element. | | getData | function | required | Async function to fetch items. Receives { offset, cursor, limit } and must return { total, items }. Each item must have an id property (string or number). | | fetchStep | number | 3 | Number of items requested per fetch call. Data is fetched preemptively as the user navigates, ensuring smooth transitions. | | hideIndex | boolean | false | Hide the index badge in the top right corner. | | showArrows | boolean | false | Show navigation arrows. Also enabled when renderArrow is provided. | | renderArrow | function | undefined | Custom render function for arrows. | | renderBadge | function | undefined | Custom render function for the index badge. |

Usage

Basic Example (Offset-based pagination)

import ReactCarouselQuery from 'react-carousel-query'
import 'react-carousel-query/styles.css' // Required for styles

const getData = async ({ offset, limit }) => {
  const response = await fetch(`https://api.example.com/items?offset=${offset}&limit=${limit}`)
  const { data } = await response.json()
  return {
    total: data.total, // Total number of items available
    items: data, // Each item must have an `id` property (string | number)
  }
}

const App = () => (
  <ReactCarouselQuery
    renderItem={({ item }) => <img src={item.imgSrc} alt={item.name} />}
    getData={getData}
  />
)

Cursor-based pagination

To use cursor-based pagination, return nextCursor in your response. The component auto-detects the pagination mode:

const getData = async ({ cursor, limit }) => {
  const url = cursor
    ? `https://api.example.com/items?cursor=${cursor}&limit=${limit}`
    : `https://api.example.com/items?limit=${limit}`

  const response = await fetch(url)
  const { data, nextCursor, totalCount } = await response.json()

  return {
    items: data,
    nextCursor, // null when there are no more pages
    total: totalCount, // optional - will be inferred from items if not provided
  }
}

For a complete working example, check out our demo code.

Setup

npm install

How to run

npm run dev

How to build

npm run build

How to test

npm test

Contributions

Contributions are welcome. Just open a PR and feel free to contact me :-).

You can also start looking into ope issues, specially the ones with good first issue label.

Documentation

Run Storybook for interactive documentation:

npm run storybook