---
title: useVirtualTree
description: "Reads the filesystem tree and its mutation actions."
---

```tsx
import { useVirtualTree } from 'filedom';

const { tree, isLoading, error, refresh } = useVirtualTree();
```

Call it inside a [VirtualTreeProvider](/docs/reference/components/virtual-tree-provider); outside one it throws. The actions change real files.

## Returns

- `tree: VirtualDesktop | null`, `isLoading: boolean`, `error: Error | null`.
- `refresh(): Promise<void>`.
- `renameItem(id, newName): Promise<void>`.
- `deleteItem(id): Promise<void>`.
- `addItem(parentId, name, type): Promise<void>`; type is `file` or `folder`, and null parent means the root.
