tanstack-virtual

v2026.09.24

TanStack Virtual for virtualizing large lists, grids, and tables. Use when rendering thousands of rows, implementing infinite scroll, or optimizing large data displays. Use for virtual, virtualize, virtual-list, virtual-scroll, useVirtualizer, infinite-scroll, windowing.

GitHub
Install command
npx skhub add oakoss/tanstack-virtual
Markdown
SKILL.md

TanStack Virtual

Overview

TanStack Virtual is a headless UI utility for virtualizing large lists, grids, and tables. It renders only the visible items in the viewport, dramatically reducing DOM nodes and improving performance for datasets with thousands of rows. Framework adapters are available for React, Vue, Solid, Svelte, Lit, and Angular.

When to use: Rendering thousands of rows or columns, building virtualized tables, implementing infinite scroll, displaying large datasets where DOM node count impacts performance.

When NOT to use: Small lists under ~100 items (no performance benefit), server-rendered static content, layouts where all items must be in the DOM for SEO or accessibility, simple pagination (render one page at a time instead).

Quick Reference

PatternAPIKey Points
Vertical listuseVirtualizer({ count, getScrollElement, estimateSize })Wrap items in absolute-positioned container
Horizontal listuseVirtualizer({ horizontal: true, ... })Use getTotalSize() for width instead of height
Grid layoutRow virtualizer + column virtualizerTwo virtualizer instances sharing one scroll element
Dynamic sizingref={virtualizer.measureElement}Set data-index on each element
Window scrolleruseWindowVirtualizer({ count, estimateSize })No getScrollElement needed
Scroll to itemvirtualizer.scrollToIndex(index)Supports align: 'start' | 'center' | 'end' | 'auto'
Scroll to offsetvirtualizer.scrollToOffset(px)Supports align and behavior: 'smooth'
Custom keysgetItemKey: (index) => items[index].idStable keys improve measurement cache
Overscanoverscan: 5Renders extra items outside viewport (default: 1)
Gap between itemsgap: 8Space between virtualized items in pixels
Multi-lane layoutlanes: 3Masonry-style column layouts
PaddingpaddingStart: 100, paddingEnd: 100Space before first and after last item
RTL supportisRtl: trueRight-to-left horizontal scrolling
Range extractorrangeExtractor: (range) => [...]Customize rendered indices (sticky headers, footers)
Disable virtualizerenabled: falseRenders nothing, resets internal state
Force remeasurevirtualizer.measure()Call after external layout changes

Common Mistakes

MistakeCorrect Pattern
Missing overflow: auto on scroll containerParent element must have overflow: auto and a fixed height/width
Using virtualItem.index as React keyUse virtualItem.key which accounts for dynamic reordering
Forgetting position: relative on inner containerThe total-size container must be position: relative
Not setting data-index with measureElementDynamic measurement requires data-index={virtualItem.index} on each element
Setting estimateSize too small for dynamic itemsOverestimate to prevent scroll jumping; use largest expected size
Recreating getScrollElement on every renderUse a ref callback: () => parentRef.current
Not using getTotalSize() for container dimensionsInner container height/width must equal virtualizer.getTotalSize()
Absolute positioning without transformUse transform: translateY(item.start) for GPU-accelerated positioning
Using contain: strict without fixed dimensionscontain: strict requires explicit width and height on the scroll container
Using with React Compiler without opting outAdd 'use no memo' directive to components using useVirtualizer — interior mutability breaks memoization

Delegation

If the tanstack-table skill is available, delegate data table virtualization to it. TanStack Table has built-in virtualization integration. Otherwise, recommend: npx skills add oakoss/agent-skills --skill tanstack-table

If the tanstack-query skill is available, delegate data fetching and infinite query patterns to it. Otherwise, recommend: npx skills add oakoss/agent-skills --skill tanstack-query

References

Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

Not specified

Source path

skills/tanstack-virtual

Default branch

main

Latest commit

85e3a39

Tree SHA

a4c9e7b