Skip to main content
The <ClientOnly> component is used for purposely rendering a component only on client side.
The content of the default slot will be tree-shaken out of the server build. (This does mean that any CSS used by components within it may not be inlined when rendering the initial HTML.)

Props

string
Specify a tag to be rendered server-side. Alias: fallbackTag
string
Specify a tag to be rendered server-side. Alias: placeholderTag
string
Specify a content to be rendered server-side. Alias: fallback
string
Specify a content to be rendered server-side. Alias: placeholder

Usage

Slots

#fallback

Specify a content to be rendered on the server and displayed until <ClientOnly> is mounted in the browser.
[app/pages/example.vue]

Examples

Accessing HTML Elements

Components inside <ClientOnly> are rendered only after being mounted. To access the rendered elements in the DOM, you can watch a template ref:
[app/pages/example.vue]