Skip to content
@pyreon/virtual
fundamentals · large lists

A hundred thousand rows. Twenty in the DOM.

TanStack Virtual with its state in Pyreon signals. Only the rows on screen exist, and a scroll adds the rows coming in and removes the ones going out: the rows that stay do no work, because there is no component to re-render.

bun add @pyreon/virtual
Documentation
vs react-virtual, Chromium
faster on all 4 operationsMount, scroll, jump, unmount. One run, author-run.
built on
@tanstack/virtual-coreSame measuring and range logic as react-virtual.
sizing
fixed, variable, measuredVertical, horizontal and masonry lanes.
scroll target
an element or the windowuseVirtualizer / useWindowVirtualizer.
A hundred thousand rows, about twenty in the DOM Schematic: a scroll track stands for 100,000 rows; a viewport shows the rows around row 41,200. Each scroll step adds the two rows coming into view and removes the two going out, while the rows that stay do no work. A counter shows about twenty rows in the DOM at every position, overscan included. USEVIRTUALIZER · ONLY THE ROWS ON SCREEN EXIST 100,000 rows 41% scroll position row 41,200row 41,201row 41,202row 41,203row 41,204row 41,205row 41,206row 41,207row 41,208row 41,209row 41,210row 41,211row 41,212row 41,213 rows in view: 8 · overscan above and below in the DOM ~20 at any scroll first row 41,20041,20241,20441,206 rows that stay do no work: there is no component to re-render
  • 3.25× faster unmount of a 10,000-row virtual list than @tanstack/react-virtual (20 vs 65 µs)BENCHMARKS.md §2 Virtual list, real Chromium · final pass, one run
  • 1.15× faster mount (777 vs 897 µs); jump to row 5,000 1.10×BENCHMARKS.md §2 Virtual list · one run
  • 20 rows in the DOM at row 50,000 of 100,000 (10 visible + 5 overscan each side)useVirtualizer with a 400 px viewport, 40 px rows and overscan: 5, mounted and scrolled to row 50,000

synthetic · author-run · M3 Max · record of 2026-11-05

Every result, including where we lose →
why teams pick it

Long lists that stay quick.

  1. Scrolling touches the edges only

    Rows render through a keyed <For by={(r) => r.index}>. A scroll step creates the rows entering and removes the rows leaving; the rest keep their DOM and run nothing.

  2. Signals out, signals in

    virtualItems(), totalSize() and isScrolling() are signals, and the options are a function that reads signals. Filter the list and count re-sizes the virtualizer on its own.

  3. Any row shape

    Fixed heights, known variable heights, or measured on render with measureElement. Horizontal lists and masonry lanes too, from the same core TanStack uses.

  4. Jump anywhere

    instance.scrollToIndex(50_000) for "go to row", scrollToOffset for a saved position.

the difference

Same core. No list re-render per scroll step.

React + @tanstack/react-virtual

Each scroll step re-renders the list component and reconciles every visible row.

function List({ rows }: { rows: string[] }) {
  const parentRef = useRef<HTMLDivElement>(null)
  const v = useVirtualizer({
    count: rows.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => 40,
    overscan: 5,
  })
  return (
    <div ref={parentRef} style={{ height: 400, overflow: 'auto' }}>
      <div style={{ height: v.getTotalSize(), position: 'relative' }}>
        {v.getVirtualItems().map((item) => (
          <div key={item.key} style={{ position: 'absolute', top: 0,
            width: '100%', height: item.size,
            transform: `translateY(${item.start}px)` }}>
            {rows[item.index]}
          </div>
        ))}
      </div>
    </div>
  )
}
with @pyreon/virtual

The component runs once. A scroll step adds and removes rows at the edges.

import { For } from '@pyreon/core'
import { useVirtualizer } from '@pyreon/virtual'

const List = (props: { rows: () => string[] }) => {
  let scrollEl: HTMLElement | null = null
  const v = useVirtualizer(() => ({
    count: props.rows().length,
    getScrollElement: () => scrollEl,
    estimateSize: () => 40,
    overscan: 5,
  }))
  return (
    <div ref={(el) => (scrollEl = el)} style="height: 400px; overflow: auto">
      <div style={() => `height: ${v.totalSize()}px; position: relative`}>
        <For each={() => v.virtualItems()} by={(item) => item.index}>
          {(item) => (
            <div style={() => `position: absolute; top: ${item.start}px; height: ${item.size}px; width: 100%`}>
              {props.rows()[item.index]}
            </div>
          )}
        </For>
      </div>
    </div>
  )
}
coming from

Coming from TanStack Virtual (React)?

Options become a function; getters become signals.

TanStack Virtual (React)
const v = useVirtualizer({
  count: rows.length,
  getScrollElement: () => parentRef.current,
  estimateSize: () => 40,
})

v.getTotalSize()
v.getVirtualItems()
v.scrollToIndex(5000)
Pyreon

Every @tanstack/virtual-core option works the same (overscan, horizontal, lanes, gap, paddingStart, measureElement…). The Virtualizer instance is on .instance; its state is mirrored into the virtualItems, totalSize and isScrolling signals.

const v = useVirtualizer(() => ({
  count: rows().length,
  getScrollElement: () => scrollEl ?? null,
  estimateSize: () => 40,
}))

v.totalSize()
v.virtualItems()
v.instance.scrollToIndex(5000)
try it

Scroll 100,000 rows.

The counters show how many rows exist in the DOM right now: about twenty at any position, out of 100,000.

  • Ada · order #100000$20
  • Grace · order #100001$57
  • Linus · order #100002$94
  • Margaret · order #100003$131
  • Edsger · order #100004$168
  • Barbara · order #100005$205
  • Ken · order #100006$242
  • Dennis · order #100007$279
  • Ada · order #100008$316
  • Grace · order #100009$353
  • Linus · order #100010$390
  • Margaret · order #100011$427
  • Edsger · order #100012$464
  • Barbara · order #100013$501
  • Ken · order #100014$538
  • Dennis · order #100015$575

Scroll with the wheel or a finger, or focus the list and use the arrow keys, Page Down and End.

  • total rows100,000
  • rows in the DOM0
  • rows added or removed by the last scroll step0

Counted from the DOM by a MutationObserver: rows that stay in view are kept as they are, so a scroll touches only the rows entering and leaving.

benchmarks

Faster on all four operations.

Same virtual-core on both sides, so the difference is rendering: React re-renders the list on every scroll step, Pyreon patches the rows entering and leaving. One run in the browser; the happy-dom rows below come from a separate harness (overnight run, one run) and include a loss at mount.

vs @tanstack/react-virtual 3.14 with memoized rows · 10,000 rows, real ChromiumPyreonrival · lower is better
  • unmount
    20 µs
    65 µs
    win3.25×
  • mount 10,000-row list
    777 µs
    897 µs
    win1.15×
  • jump to row 5,000
    315 µs
    345 µs
    win1.10×
  • scroll 60 steps of 5 rows
    3.53 ms
    3.68 ms
    win1.04×
  • happy-dom: scroll → DOM
    win1.4×
  • happy-dom: mount 10k list
    lossreact-virtual 1.1×
Apple M3 Max · record of 2026-11-05 · final pass, one run · author-run, syntheticFull method, every loss →
what's included

Virtualization, the TanStack way, with signals.

  • useVirtualizer For a scrolling element; returns virtualItems, totalSize, isScrolling and the core instance.
  • useWindowVirtualizer For a list that scrolls with the page; safe to render on the server.
  • Reactive options Read a signal in count and the virtualizer follows. Changed a size estimate? One instance.measure() re-sizes the list.
  • item(index) Per-index start, size and lane accessors for measured rows, at no cost until you use them.
  • Measured rows measureElement corrects an estimate once a row renders.
  • Horizontal and lanes horizontal: true for carousels, lanes for masonry grids.
  • scrollToIndex / scrollToOffset Go to row 50,000, or back to where the user was.
  • Overscan Render a few rows past each edge so fast scrolls do not flash blank.
  • Detached at mountnext release A scroll element inserted after mount (a <Show>, a portal) gets its observers re-attached instead of rendering zero rows.
  • Core utilities re-exported Virtualizer, elementScroll, windowScroll, measureElement, defaultRangeExtractor and the observers.
recipes

Things to build with it.

A filtered contact list

The count reads a computed, so typing in the search box re-sizes the list and keeps only the visible matches in the DOM.

import { computed, signal } from '@pyreon/reactivity'
import { useVirtualizer } from '@pyreon/virtual'

const query = signal('')
const visible = computed(() =>
  contacts().filter((c) => c.name.toLowerCase().includes(query().toLowerCase())),
)

const v = useVirtualizer(() => ({
  count: visible().length,
  getScrollElement: () => scrollEl ?? null,
  estimateSize: () => 56,
  overscan: 8,
}))
A feed that scrolls with the page

No inner scroll box: the window is the scroller, and rows of different heights are measured as they render.

import { For } from '@pyreon/core'
import { useWindowVirtualizer } from '@pyreon/virtual'

const v = useWindowVirtualizer(() => ({
  count: posts().length,
  estimateSize: () => 240,
}))

<div style={() => `height: ${v.totalSize()}px; position: relative`}>
  <For each={() => v.virtualItems()} by={(it) => it.index}>
    {(it) => (
      <article
        data-index={it.index}
        ref={(el) => v.instance.measureElement(el)}
        style={() => `position: absolute; top: ${v.item(it.index).start()}px; width: 100%`}
      >
        {posts()[it.index]?.body}
      </article>
    )}
  </For>
</div>
api

Two hooks and the TanStack core.

Every export has a reference page with its signature, an example and the mistakes people make with it.

hooks · 2
  • useVirtualizer
  • useWindowVirtualizer
result · 5
  • virtualItems
  • totalSize
  • isScrolling
  • item
  • instance
core · 10
  • Virtualizer
  • elementScroll
  • windowScroll
  • measureElement
  • observeElementRect
  • observeElementOffset
  • observeWindowRect
  • observeWindowOffset
  • defaultKeyExtractor
  • defaultRangeExtractor
types · 11
  • UseVirtualizerOptions
  • UseVirtualizerResult
  • UseWindowVirtualizerOptions
  • UseWindowVirtualizerResult
  • VirtualItem
  • VirtualizerOptions
  • Range
  • Rect
  • ScrollToOptions
  • ItemRegistry
  • VirtualItemMeasurement
good to know

Good to know before you start.

Give a close estimateSize

The scrollbar is sized from it before rows are measured. A close guess keeps the thumb from jumping.

Find-in-page sees rendered rows only

Rows outside the window are not in the DOM, so the browser's search cannot find them. Put a search box on long lists.

Key rows by index

Use <For by={(item) => item.index}> so a scroll moves only the edges. A .map() without a key rebuilds every visible row.

Native lists are already lazy

On iOS and Android (native targets are experimental), put a <For> as the only child of <Scroll> and it becomes a LazyVStack or LazyColumn, no virtualizer needed. @pyreon/virtual itself is web.

questions

What people ask first.

How does it compare with react-virtual?

Same virtual-core, rendered differently. In real Chromium at 10,000 rows, one run: mount 1.15×, 60 scroll steps 1.04×, jump to row 5,000 1.10×, unmount 3.25× faster. Under happy-dom the record shows scroll-to-DOM 1.4× faster and mount 1.1× slower; happy-dom is a JavaScript DOM, the browser figure is the one that counts.

Do I need it for a table?

For a few hundred rows, no. Past a few thousand, pair it with @pyreon/table: virtualize the row model and render only the window.

Does it work with server rendering?

useWindowVirtualizer checks for a browser before touching window, and both hooks start measuring on mount, so the server renders the list shell and the client fills the window.

Variable heights?

Yes. Pass a per-index estimateSize, or measure rows with measureElement and a data-index attribute, as in TanStack.

Ninety-nine thousand nine hundred and eighty rows, doing nothing.

bun add @pyreon/virtual
Read the virtual guide