A Vue 3 plugin for client-side HTML sanitization, wrapping the popular sanitize-html library. Current stable version is 0.3.0 (released 2023-09-07, semver patch). Ships TypeScript types, requires Node >=18 and Vue ^3.0. Allows both Options API (this.$sanitize) and Composition API (useSanitize) usage. Supports per-call and default configuration options. Useful for scenarios like live markdown previews or rich text pasting where server-side sanitization must be complemented.
npm install vue-sanitizeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Registers the plugin with custom sanitize-html options and demonstrates sanitizing untrusted HTML in both Options and Composition API.
Use vue-sanitize@0.2.0 for Vue 2 (unsupported) or migrate to Vue 3.
Always sanitize on the server; use this plugin only for live previews or paste handling.
Use ES import syntax. If you need CommonJS, pin to version 0.1.0 (Vue 3) but it's deprecated.
If you need to extend defaults per call, you must re-specify all desired options or merge manually.
Pin sanitize-html version via package.json resolutions if you depend on specific defaults.
Ensure your project has 'moduleResolution': 'node' (or 'node16') in tsconfig.json. The package ships types, so no @types/vue-sanitize needed.
Call `app.use(VueSanitize)` before mounting the app. Ensure component is a Vue 3 component.
Use `import` syntax instead of `require()`. If your project is CommonJS, upgrade to ESM or downgrade to vue-sanitize@0.1.0.
const sanitize = useSanitize(); // returns the sanitize function, then sanitize(dirty)