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

@myzbox/react-virtual-list

v1.1.0

Published

A lightweight, smooth, headless React hook for fixed-height list virtualization, built for performance and large datasets.

Readme

@myzbox/react-virtual-list

npm npm downloads license types react GitHub stars

A lightweight, smooth, headless React hook for fixed-height list virtualization, built for performance and large datasets.

Render 10,000+ items smoothly without killing the DOM.


✨ Features

  • ⚡ Smooth scrolling using requestAnimationFrame
  • 🧠 Headless hook (UI-agnostic)
  • 📏 Fixed-height list virtualization
  • 📱 Responsive container using ResizeObserver
  • 🚀 Optimized for large datasets (10k+ items)
  • ✅ Works with JavaScript & TypeScript
  • 🔒 React 18 compatible
  • 📦 Small bundle size

📦 Installation

npm install @myzbox/react-virtual-list

yarn add @myzbox/react-virtual-list

🚀 Basic Usage

import React from "react";
import { useVirtualList } from "@myzbox/react-virtual-list";

export default function TestVirtualList() {
  const data = Array.from({ length: 10000 }, (_, i) => `Item ${i + 1}`);

  const { containerRef, virtualItems, totalHeight } = useVirtualList({
    count: data.length,
    itemHeight: 40,
    overscan: 8,
  });

  return (
    <div style={{ padding: "20px" }}>
      <h2>Virtual List Test</h2>

      <div
        ref={containerRef}
        style={{
          height: "80vh",
          overflow: "auto",
          border: "1px solid #ccc",
          position: "relative",
        }}
      >
        <div style={{ height: totalHeight, position: "relative" }}>
          {virtualItems.map((item) => (
            <div
              key={item.index}
              style={{
                position: "absolute",
                transform: `translateY(${item.start}px)`,
                height: item.size,
                width: "100%",
                display: "flex",
                alignItems: "center",
                padding: "0 16px",
                boxSizing: "border-box",
                borderBottom: "1px solid #eee",
                color: "#4B5563",
                background: item.index % 2 === 0 ? "#fafafa" : "#fff",
              }}
            >
              {data[item.index]}
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

🧩 API Reference

useVirtualList(options)

| Option | Type | Required | Description | | ------------ | -------- | -------- | -------------------------------------------------------- | | count | number | ✅ | Total number of items | | itemHeight | number | ✅ | Height of each item (px only) | | overscan | number | ❌ | Extra items rendered above/below viewport (default: 5) |

Return Values

{
  containerRef: RefObject<HTMLDivElement>;
  virtualItems: {
    index: number;
    start: number;
    size: number;
  }
  [];
  totalHeight: number;
}

| Property | Description | | -------------- | ------------------------------------- | | containerRef | Attach to the scroll container | | virtualItems | Items currently rendered | | totalHeight | Total scroll height (used for spacer) |

📐 Layout Rules (IMPORTANT)

✅ Allowed

Container height can use vh, %, or px

style={{ height: "90vh" }}

❌ Not Allowed

Item height must NOT use vh or %

itemHeight: 32; // ✅ pixels only

Reason: virtualization math requires numeric pixel values.

⚡ Performance Notes

Uses requestAnimationFrame to avoid scroll jank

Uses ResizeObserver to handle container resizing

Uses GPU-accelerated transforms (translateY)

Renders only visible rows + overscan buffer

🧠 When to Use This Library

✅ Large lists (logs, feeds, dashboards) ✅ Fixed-height rows ✅ Performance-critical UI ✅ When you want full rendering control

❌ Variable-height rows (planned for v2)

JavaScript & TypeScript Support

JavaScript apps consume compiled .js files

TypeScript apps get full .d.ts typings

No additional configuration required

🧪 Example Use Cases

Activity feeds

Chat message lists

Audit logs

Admin dashboards

Large dropdown menus

🛣 Roadmap

v1.0.x – Stability & performance improvements

v1.1.0 – Scroll-to-index API

v2.0.0 – Variable-height virtualization (breaking change)

See ROADMAP.md for details.

🤝 Contributing

Contributions are welcome!

Please read CONTRIBUTING.md before submitting a pull request.

👤 Maintainer

Name: Mahantesh Teli
Email: [email protected]
Organization: myZbox

For questions, bug reports, or feature requests, please open an issue. Direct emails are recommended only for security or private concerns.

📄 License

MIT © 2025 myzbox

⭐ Support

If this library helps you:

Star the repository ⭐

Share feedback

Open issues for bugs or feature requests