---
title: "ssr:beforeRender Hook · Unhead"
canonical_url: "https://unhead.unjs.io/docs/nuxt/head/api/hooks/ssr-before-render"
last_updated: "2026-09-02T22:04:29.763Z"
meta:
  description: "Hook for allowing or canceling an SSR head render before tag resolution begins."
  "og:description": "Hook for allowing or canceling an SSR head render before tag resolution begins."
  "og:title": "ssr:beforeRender Hook · Unhead"
---

Home

`
Unhead on GitHub

Switch to NuxtSwitch to TypeScriptSwitch to VueSwitch to ReactSwitch to SvelteSwitch to Solid.jsSwitch to Angular

**Hooks**

# **ssr:beforeRender Hook**

[Copy for LLMs](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/head/7.api/hooks/12.ssr-before-render.md)

The `**ssr:beforeRender**` hook runs at the start of `**head.render()**`, before Unhead resolves any tags. Set `**ctx.shouldRender**` to `**false**` to return an empty `**SSRHeadPayload**` and skip the remaining SSR hooks.

## Hook Signature

```
export interface Hook {
  'ssr:beforeRender': (ctx: ShouldRenderContext) => HookResult
}

interface ShouldRenderContext {
  shouldRender: boolean
}

type HookResult = void | Promise<void>
```

Although the type permits a promise, the synchronous SSR renderer does not await hook results. Make changes to `**ctx**` synchronously.

## Usage Example

```
import { defineHeadPlugin } from '#imports/plugins'

export function conditionalSsrPlugin(shouldRenderHead: () => boolean) {
  return defineHeadPlugin({
    key: 'conditional-ssr',
    hooks: {
      'ssr:beforeRender': (ctx) => {
        ctx.shouldRender = shouldRenderHead()
      }
    }
  })
}
```

If you cache rendered head output, perform the cache lookup outside `**head.render()**`. Canceling this hook returns an empty payload; it does not substitute cached HTML.

[Edit this page](https://github.com/unjs/unhead/edit/main/docs/head/7.api/hooks/12.ssr-before-render.md)

[Markdown For LLMs](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/head/7.api/hooks/12.ssr-before-render.md)

**Did this page help you? **

[**dom:beforeRender** Synchronous hook for allowing or canceling a pending client-side DOM render.](https://unhead.unjs.io/docs/head/api/hooks/dom-before-render) [**ssr:render** Hook for changing resolved tags and per-render serialization options during SSR.](https://unhead.unjs.io/docs/head/api/hooks/ssr-render)

**On this page **

- [Hook Signature](#hook-signature)
- [Usage Example](#usage-example)