---
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"
last_updated: "2026-08-11T00:38:16.415Z"
---

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/dynamic-import/plugins'

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