onBeforeRenderClient()
hook
Environment: client
Cumulative: true
Global: false
Provided by: vike-react
/vike-vue
You need to install
vike-react
/vike-vue
to be able to useonBeforeRenderClient()
. If you don't usevike-react
/vike-vue
then see Withoutvike-{react,vue,solid}
.
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 async function onBeforeRenderClient(pageContext) { if (pageContext.isHydration) { // ... } }
It's called by vike-{react,vue}
at the beginning of its onRenderClient()
implementation.
Without vike-{react,vue,solid}
If you don't use any UI framework Vike extension vike-react
/vike-vue
/vike-solid
then use the onRenderClient()
hook instead.