---
title: "dom:beforeRender Hook"
description: "Synchronous hook for allowing or canceling a pending client-side DOM render."
canonical_url: "https://unhead.unjs.io/docs/head/api/hooks/dom-before-render"
---

> Index of every page on this site: [llms.txt](https://unhead.unjs.io/llms.txt)

The `dom:beforeRender` hook runs immediately before the client renderer resolves tags and patches the document. Set `ctx.shouldRender` to `false` to cancel that render.

## Hook Signature

```ts
export interface Hook {
  'dom:beforeRender': (ctx: DomBeforeRenderCtx) => SyncHookResult
}

interface DomBeforeRenderCtx {
  shouldRender: boolean
  tags: HeadTag[]
}
```

The hook is synchronous. In the current renderer, `ctx.tags` is initialized to an empty array because tag resolution happens after this hook. Use a `tags:*` hook to inspect tags.

Canceling a render does not clear the head's dirty state. A later update or explicit `head.render()` call can try again.

## Usage Example

```ts
import { defineHeadPlugin } from 'unhead/plugins'

export function pauseDomRendering(isPaused: () => boolean) {
  return defineHeadPlugin({
    key: 'pause-dom-rendering',
    hooks: {
      'dom:beforeRender': (ctx) => {
        if (isPaused())
          ctx.shouldRender = false
      }
    }
  })
}
```

## Sitemap

See the full [sitemap](https://unhead.unjs.io/sitemap.md) for all pages.
