onBeforeRenderClient() hook

Environment: client.

Implemented by: vike-react/vike-vue.

You need vike-react/vike-vue to be able to use onBeforeRenderClient().

Hook called at the beginning of rendering the page on the client-side. It's usually used for integrating tools, such as state management tools.

It's called upon rendering the first page (e.g. hydration when using SSR) and upon page navigation.

If you want to perform an action only upon hydration then use pageContext.isHydration:

// +onBeforeRenderClient.js
 
export function onBeforeRenderClient(pageContext) {
  if (pageContext.isHydration) {
    // ...
  }
}

It's called by vike-{react,vue} at the beginning of its onRenderClient() implementation.

See also