Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

universal-dompurify

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-dompurify

💎 Use DOMPurify for some context by conditional exports

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
470
increased by29.12%
Maintainers
1
Weekly downloads
 
Created
Source

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 Export applies the appropriate file at each runtime.

import DOMPurify from 'universal-dompurify'

const cleaned = DOMPurify.sanitize(/* ... */)
RuntimeResolve
BrowserDOMPurify
Node ServerDOMPurify + JSDOM
EdgeDOMPurify + 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'
RuntimeResolve
BrowserDOMPurify
Servernull
Edgenull

Keywords

FAQs

Package last updated on 05 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc