vue-client-only is a Vue 2 component designed to conditionally render child components exclusively on the client-side, bypassing server-side rendering (SSR). This is particularly useful for integrating third-party libraries or components that rely on browser APIs, making them incompatible with SSR environments. The current stable version is 2.1.0, released in June 2021. The project has an infrequent release cadence, with the last major update (v2.0.0) in 2019 renaming the component from `<no-ssr>` to `<client-only>`. Its primary differentiation lies in its simplicity for isolating client-only code within a Vue 2 application, offering a slot or prop for a placeholder during SSR. It provides basic client-side rendering capabilities without requiring complex SSR configurations.
npm install vue-client-onlyVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing and using the ClientOnly component with both slot-based and prop-based placeholders, highlighting its use case for isolating client-side components in an SSR application.
Replace all `<no-ssr>` tags with `<client-only>` and update any CSS targeting `.no-ssr-placeholder` to target `.client-only-placeholder`.
Update your CSS selectors to use `.client-only-placeholder` instead of `.no-ssr-placeholder` for styling the SSR placeholder.
If migrating to Vue 3, assess if your framework (e.g., Nuxt 3, VitePress) offers a native `<ClientOnly>` component. Otherwise, investigate alternative Vue 3-compatible solutions for conditional client-side rendering.
Verify `"typeRoots": ["./node_modules/@types", "./types"]` or similar is correctly configured in your `tsconfig.json` and ensure `"allowSyntheticDefaultImports": true` might be needed for default exports if using certain module setups.
Choose one method for providing placeholder content. For rich HTML, use the `#placeholder` slot. For simple text, the `placeholder` prop is sufficient. Be aware of the precedence order.
Update all instances of `<no-ssr>` in your templates to `<client-only>`.
Ensure `import ClientOnly from 'vue-client-only'` is used and `ClientOnly` is listed in the `components` option of your Vue component.
Change your import statement to `import ClientOnly from 'vue-client-only';`