<!-- https://svgrid.com/docs/recipes/lazy-load-expand/ - SvGrid documentation as markdown. Index of every page: https://svgrid.com/llms.txt -->

# Lazy-load expand on demand

> Live in [demo 31-lazy-tree-load](https://svgrid.com/demos/31-lazy-tree-load/).

> Live demo: Lazy tree (load on expand) - https://svgrid.com/demos/31-lazy-tree-load/

## When

Tree rows where children are fetched only when the user expands their parent.

## How

Key API surface:

- `onExpand callback`
- `merge children into $state on resolve`

See the demo source for the full implementation; this recipe pins the
pattern + the surface so you can copy-paste it confidently. The doc
page that explains the underlying feature in depth is linked from the
[recipes index](https://github.com/sv-grid/sv-grid/blob/main/docs/recipes/index.md).

## See also

- [Demo 31-lazy-tree-load source](https://github.com/sv-grid/sv-grid/blob/main/examples/src/demos/31-lazy-tree-load.svelte)
- [Demo 31-lazy-tree-load prompt sidecar](https://github.com/sv-grid/sv-grid/blob/main/examples/src/demos/prompts/31-lazy-tree-load.md) - drop into an LLM context window
- [Recipes index](https://github.com/sv-grid/sv-grid/blob/main/docs/recipes/index.md)

---

SvGrid is the Svelte 5 data grid (`npm install @svgrid/grid`, MIT). This page: https://svgrid.com/docs/recipes/lazy-load-expand/ . All docs: https://svgrid.com/llms.txt
