# useWidgetsGetter

Source: https://sdk.pdf.net/docs/v1/reference/useWidgetsGetter



Returns an asynchronous callback that resolves with all document widgets in reading order, for imperative whole-form operations: exporting values, bulk edits, lookups inside event handlers.

```ts
const getWidgets = useWidgetsGetter()

const widgets = await getWidgets()
```

* The callback loads every page containing widgets before resolving, so the result is always complete; that load can take a while on a large document the first time.
* The entries are the same `Widget` snapshots as in [useWidgets](https://sdk.pdf.net/docs/v1/reference/useWidgets). Prefer `useWidgets` when the widgets are rendered: it re-renders on changes, while the getter is a one-time read.
* With no document loaded, the callback resolves with an empty array.

## Example [#example]

```tsx
import { useBlockDelete, useWidgetsGetter } from '@sdk-pdf/react'

function useDeleteWidgetsByFieldName() {
  const getWidgets = useWidgetsGetter()
  const deleteBlocks = useBlockDelete()

  return async (fieldName: string) => {
    const widgets = await getWidgets()
    deleteBlocks(
      widgets
        .filter((widget) => widget.fieldName === fieldName)
        .map((widget) => widget.id)
    )
  }
}
```

