Detalhes do pacote

universal-dompurify

jill643.5kMIT1.0.25

💎 Use DOMPurify for some context by conditional exports

dompurify, html, isomorphic, sanitize

readme (leia-me)

universal-dompurify

npm-version npm-license npm-download-month npm-min-size

💎 Use DOMPurify for some context by conditional exports

Installation

npm i universal-dompurify

Usage

Conditional exports apply the appropriate DOMPurify file at each run.

import DOMPurify from 'universal-dompurify'

const cleaned = DOMPurify.sanitize(/* ... */)
condition resolve
browser DOMPurify
default DOMPurify + JSDOM
worker DOMPurify + JSDOM + (require: your external node polyfills)

[!TIP] It is generally not recommended to use JSDOM with the restricted Edge runtime.
See also @jill64/universal-sanitizer for a more lightweight alternative.

Browser Only Mode

Reduces bundle size by omitting rendering on the server.

/** @type {DOMPurify | null} */
import DOMPurify from 'universal-dompurify/browser-only'

const cleaned = DOMPurify?.sanitize?.(/* ... */) ?? 'server-fallback-value'
condition resolve
browser DOMPurify
default null
worker null

License

MIT