---
title: useDesktopSelection
description: "Tracks selected Finder paths."
---

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

const { selection } = useDesktopSelection();
```

## Parameters

```ts
useDesktopSelection(
  onSelectionChange?: ((paths: string[]) => void)
)
```

`onSelectionChange`: optional callback that receives the selected paths on each change.

## Returns

`selection: string[]`, the current selection, and `setSelection(paths)`. Finder does not allow desktop icons to be selected programmatically, so `setSelection` only affects Finder windows.
