UNPKG

@4350pchris/vue-dynamic-client-only

Version:

A Vue 3 component that renders its children only on the client using a dynamic component.

2 lines (1 loc) 792 B
(function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.ClientOnly={},n.Vue))})(this,function(n,e){"use strict";const l=e.defineComponent({__name:"ClientOnly",props:{load:{}},setup(i){const s=i,t=e.useSlots(),c=e.defineAsyncComponent({loader:s.load,loadingComponent:t.fallback,errorComponent:t.error??(()=>e.h("p","Error loading component")),onError:o=>{throw console.error("Component loading failed:",o),o},suspensible:!1}),r=e.ref(!1);return e.onMounted(()=>{r.value=!0}),(o,d)=>r.value?(e.openBlock(),e.createBlock(e.unref(c),{key:0})):e.createCommentVNode("",!0)}});n.ClientOnly=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});