Description
server-dom-shim is a small package that stops server-side rendering from failing on browser-only DOM classes. When code that refers to HTMLElement runs on a server, Node.js does not define it, and the render fails with an error saying HTMLElement is not defined. This package avoids that by exporting different code depending on where it runs. It uses Node.js conditional exports, so in Node.js it provides the DOM API from the @lit-labs/ssr-dom-shim package, and in a browser it exports the native DOM API. The browser build therefore keeps the real DOM behaviour, and the server gets a working stand-in. The project is a single small library with a short README, and it is released under the MIT license with its source on GitHub.…
Highlights
- Stops HTMLElement is not defined errors on the server
- Conditional exports for Node.js and browsers
- Server side uses @lit-labs/ssr-dom-shim
- Browsers get the native DOM API
- MIT licensed
Ratings & Reviews
No ratings yet
Be the first to rate server-dom-shim.
People also visit
Happy Dom
A JavaScript implementation of a web browser without its graphical user
server-dom-shim FAQ
What problem does it solve?
Server-side rendering fails with an HTMLElement is not defined error when DOM classes are used on Node.js. This package provides stand-ins on the server.
Is it free?
Yes. It is released under the MIT license.
Does it change the code in the browser?
No. In a browser the package exports the native DOM API, so browser behaviour is unchanged.
What does it use on the server?
In Node.js it exports the DOM API from the @lit-labs/ssr-dom-shim package.
What are the best server-dom-shim alternatives?
Popular alternatives to server-dom-shim include @webcomponents/shadydom, @lwc/synthetic-shadow and dom-helpers. See all server-dom-shim alternatives
















