# useSuspenseRead

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

Reads with an action and suspends until the value is there; failures throw to the nearest error boundary. Signature, result and examples for useSuspenseRead.

Source: https://ensforge.com/docs/reference/react/use-suspense-read

<ApiMeta kind="Read hook" stability="stable" since="1.0.0" source="packages/react/src/hooks/useSuspenseRead.ts#L68" />

Reads with an action and suspends until the value is there; failures throw to the nearest
error boundary.

## When to use [#when-to-use]

Use inside `<Suspense>` boundaries, including server-rendered pages whose reads were
prefetched.

## Details [#details]

- A failure is cached and thrown again until `reset` (`useReadErrorReset`, or
  `ReadErrorResetBoundary`) is called, which an error boundary's reset does; the read then runs
  again.
- On the server, a read that was not prefetched throws, so React renders the boundary's
  fallback there and the read in the browser (React reports it as a recoverable error).

## Signature [#signature]

```ts
function useSuspenseRead<action extends Action>(action: action, options: ActionOptions<action>, config: Omit<ReadConfig, "enabled"> = {}): SuspenseReadResult<ActionValue<action>>
```

## Examples [#examples]

```tsx title="A profile behind Suspense"
import { Actions } from "@ensforge/sdk"
import { useSuspenseRead } from "@ensforge/react"

function Url({ name }: { name: string }) {
  const { data } = useSuspenseRead(Actions.record.getText, { name, key: "url" })
  return <a href={data ?? "#"}>{data}</a>
}
```

## See also [#see-also]

- The [hook types](/docs/reference/react#types): `ReadResult`, `WriteResult` and `ReadConfig`.