⚠️ You are looking at the english version of the page. Help us translate it here.

API: The <client-only> Component

This component is used to purposely render a component only on client-side.

Warning: If you are using a version of Nuxt < v2.9.0, use <no-ssr> instead of <client-only>

Props:

  • placeholder: string
    • Use a text as placeholder until <client-only /> is mounted on client-side.
<template>
  <div>
    <sidebar />
    <client-only placeholder="Loading...">
      <!-- this component will only be rendered on client-side -->
      <comments />
    </client-only>
  </div>
</template>

Slots:

  • placeholder:

    • Use a slot as placeholder until <client-only /> is mounted on client-side.
    <template>
    <div>
      <sidebar />
      <client-only>
        <!-- this component will only be rendered on client-side -->
        <comments />
    
        <!-- loading indicator, rendered on server-side -->
        <comments-placeholder slot="placeholder" />
      </client-only>
    </div>
    </template>

This component is imported from egoist/vue-client-only. Thanks @egoist!

Vous avez vu une erreur ou vous souhaitez contribuer à la documentation ? Éditez cette page sur GitHub !

Platinum Sponsors

Storyblok
Support Us