vue-web-component-wrapper is a Vue 3 plugin that facilitates the creation of reusable web components (custom elements) from full-fledged Vue applications. The current stable version is 1.7.7, with frequent patch and minor releases addressing bug fixes and introducing new features. This library differentiates itself by providing comprehensive support for the broader Vue ecosystem, including seamless integration with state management (Vuex, Pinia), routing (Vue Router), internationalization (Vue I18n), and validation (VeeValidate). It also offers robust compatibility with popular CSS frameworks like Tailwind CSS, Bootstrap, and Vuetify, alongside support for CSS preprocessors and scoped styles. Key features include Shadow DOM encapsulation, Vue DevTools integration, full slot and `v-model` support, event emitting, `provide`/`inject`, and options for fine-grained control over Shadow DOM behavior and CSS styling (e.g., `:root` to `:host` replacement). It also supports async initialization and loader mechanisms.
npm install vue-web-component-wrapperVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a basic Vue 3 component, create a Vue application instance from it, and then use `vue-web-component-wrapper` to register it as a custom element. It showcases prop passing, event emitting, and slot handling within the web component context.
Understand the implications of `disableShadowDOM` and `replaceCssRootToHost` options on your component's styling. Adjust the wrapper configuration or component styles to achieve the desired encapsulation or global styling behavior, and thoroughly test for style conflicts.
Upgrade to `vue-web-component-wrapper@1.7.7` or newer to leverage the built-in CSP `nonce` handling feature. For projects unable to upgrade, ensure your CSP explicitly permits inline styles and scripts, or implement a custom solution for CSP compatibility.
Familiarize yourself with your browser's developer tools settings for inspecting Shadow DOM. Utilize the Vue DevTools extension for component-specific debugging, but be prepared for the added layer of encapsulation when inspecting the DOM structure.
Upgrade to `vue-web-component-wrapper@1.6.9` or newer, which includes a specific fix addressing this warning when building with Vite.
Upgrade to `vue-web-component-wrapper@1.6.5` or newer to resolve known TypeScript definition issues and ensure proper type inference and compilation.
Upgrade to `vue-web-component-wrapper@1.6.11` or newer. This version includes a fix that addresses issues with slot processing and nested elements when Shadow DOM is disabled.