Gathering detailed insights and metrics for @duannx/vue-client-only
Gathering detailed insights and metrics for @duannx/vue-client-only
Gathering detailed insights and metrics for @duannx/vue-client-only
Gathering detailed insights and metrics for @duannx/vue-client-only
npm install @duannx/vue-client-only
Typescript
Module System
Min. Node Version
Node Version
NPM Version
46.7
Supply Chain
98.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
TypeScript (39.96%)
Vue (35.25%)
JavaScript (14.87%)
HTML (9.92%)
Total Downloads
110,348
Last Day
26
Last Week
179
Last Month
1,028
Last Year
45,236
9 Stars
19 Commits
1 Forks
1 Watching
3 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.3
Package Id
@duannx/vue-client-only@1.0.3
Unpacked Size
12.01 kB
Size
4.29 kB
File Count
10
NPM Version
8.5.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last day
-38.1%
26
Compared to previous day
Last week
-38.5%
179
Compared to previous week
Last month
-39.7%
1,028
Compared to previous month
Last year
-15.5%
45,236
Compared to previous year
1
6
This component helps you to render a component on the client side only. Only support Vue3
1npm install --save @duannx/vue-client-only 2or 3yarn add @duannx/vue-client-only
1import ClientOnly from '@duannx/vue-client-only' 2 3<client-only> 4 <some-component></some-component> 5 This will be render only in the client 6 <template #placeholder> 7 This is the placeholder that will be render on SSR 8 </template> 9</client-only>
Use the placeholder
slot to render something on SSR
1<client-only> 2 This will be render only in the client 3 <template #placeholder> 4 This is the placeholder that will be render on SSR 5 </template> 6</client-only>
is-show
: Boolean. Use this prop to control exactly when the component is rendered on the client. If you don't set this prop, the component will be rendered on the client only when the component is mounted.1<!-- The default slot will be shown only when isShow is set to true --> 2<client-only :is-show="isShow"> 3 This will be render only in the client 4 <template #placeholder> 5 This is the placeholder that will be render on SSR 6 </template> 7</client-only>
Hydration mismatch
. NO. Please. This error is caused by the state of the component in the client is not matching with the state in the server or some incorrect HTML nesting tags. You need to find the root cause and fix it. You need to find the root cause and fix it. Overuse of this component will eliminate the benefit of SSR.is-show
prop will help you. Almost the time, the under-the-fold content is not useful when the page loads. So you can defer the rendering of all under-the-fold content till the page is loaded or the user interacts with the page.
Example, this code delay the rendering of the content till the user click or scroll the page:1<script setup> 2 import ClientOnly from '@duannx/vue-client-only' 3 import { onMounted } from '@vue/runtime-core' 4 const isShow = ref(false) 5 onMounted(() => { 6 ['keydown', 'click', 'touchstart', 'scroll'].forEach((type) => { 7 addEventListener(type, () => { 8 isShow.value = true 9 }, { once: true, capture: true }); 10 }) 11 }) 12</script> 13<template> 14Some above the fold content ... 15<ClientOnly :is-show="isShow"> 16 <p>This content is loaded after the user input</p> 17 <template #placeholder> 18 <p>Content placeholder. Click anywhere to show the main content...</p> 19 </template> 20</ClientOnly> 21</template> 22
This DEMO only has the client side. It shows how the component looks like in the client. Demo code
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
vue-client-only use SemVer for versioning.
This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.