npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

isomorphic-dompurify

v3.1.0

Published

Makes it possible to use DOMPurify on server and client in the same way.

Downloads

8,957,220

Readme

Isomorphic DOMPurify

npm version Test Status

The library makes it possible to seamlessly use DOMPurify on both server and client in the same way. It does nothing by itself except for providing an isomorphic/universal wrapper around DOMPurify, so all credits go to DOMPurify authors and contributors.

DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks.

Motivation

DOMPurify needs a DOM tree to work with, which is not available in Node by default. To work on the server side, we need a fake DOM to be created and supplied to DOMPurify. It means that DOMPurify initialization logic on the server is not the same as on the client.

This project was born with the idea of encapsulating DOMPurify initialization details and providing an easy way to import the library on both server and client, for example in Next.js apps.

It was inspired by Isomorphic Unfetch.

Requirements

| isomorphic-dompurify | Node.js | Environment | | ------------- | ------------- | ------------- | | <=0.19.0 | >=12 | Server | | >=0.20.0 | >=14 | Server | | >=1.4.0 | >=16 | Server | | >=1.10.0 | >=18 | Server | | >=2.27.0 | >=20 | Server | | >=2.30.0 | >=20.19.5 | Server | | >=3.0.0 | ^20.19.0 \|\| ^22.12.0 \|\| >=24.0.0 | Server |

Installation

$ npm i isomorphic-dompurify

Updates

Please note that the DOMPurify library doesn't follow Semantic Versioning, so we have to release every change as a minor version because we cannot be 100% sure whether new features are added to patch DOMPurify releases or not.

Usage

import DOMPurify from "isomorphic-dompurify";

const clean = DOMPurify.sanitize(dirtyString);

You can pass the config as a second argument:

const clean = DOMPurify.sanitize(dirtyString, { USE_PROFILES: { html: true } });

Named imports are also supported:

import { sanitize } from "isomorphic-dompurify";

const clean = sanitize(dirtyString);

Memory Management (Server)

In long-running Node.js processes, the internal jsdom window accumulates DOM state across sanitization calls, which can cause progressive slowdown and memory growth. Use clearWindow() to periodically release these resources:

import { sanitize, clearWindow } from "isomorphic-dompurify";

// Sanitize as usual
const clean = sanitize(dirtyString);

// Release jsdom resources when appropriate (e.g. after a request, after a batch)
clearWindow();

clearWindow() closes the current jsdom window and creates a fresh one. All import styles (default and named) continue to work after calling it.

Note: Any hooks or config set via addHook/setConfig will need to be re-applied after calling clearWindow(). In the browser build, clearWindow() is a no-op.

Web Worker Support

The isomorphic-dompurify library is compatible with Web Workers, however, dompurify, which it depends upon, is not, at least not yet.

Playgrounds

Want to try isomorphic-dompurify with your favorite framework? Check out isomorphic-dompurify-playgrounds — minimal setups for popular frameworks including Astro, Next.js, Nuxt, React and Svelte.

Known Issues

  • ERR_REQUIRE_ESM in CommonJS environments (v3.0.0+): jsdom@28 pulls in an ESM-only dependency that breaks require() in environments like Next.js on Vercel. Workaround: pin jsdom to 25.0.1 via package manager overrides. See #394.

License

DOMPurify - Apache 2.0 or MPL 2.0 © 2015 Mario Heiderich

Isomorphic DOMPurify - MIT License © 2020 Konstantin Komelin and contributors