# uhtml-ssr

> uhtml for Service Worker, Web Worker, NodeJS, and other SSR cases

Latest version **0.9.1** (published 2022-05-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install uhtml-ssr
pnpm add uhtml-ssr
yarn add uhtml-ssr
bun add uhtml-ssr
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2022-05-19 |
| First published | 2020-12-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 36.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | uhtml, SSR, worker |

## Links

- npm: https://www.npmjs.com/package/uhtml-ssr
- Repository: https://github.com/WebReflection/uhtml-ssr
- Homepage: https://github.com/WebReflection/uhtml-ssr#readme
- Issues: https://github.com/WebReflection/uhtml-ssr/issues
- npm.io page: https://npm.io/package/uhtml-ssr

## Dependencies (6)

- [uhyphen](https://npm.io/package/uhyphen.md) ^0.1.0
- [async-tag](https://npm.io/package/async-tag.md) ^0.2.0
- [uhandlers](https://npm.io/package/uhandlers.md) ^0.6.1
- [html-escaper](https://npm.io/package/html-escaper.md) ^3.0.3
- [@webreflection/mapset](https://npm.io/package/@webreflection/mapset.md) ^1.0.1
- [@webreflection/uparser](https://npm.io/package/@webreflection/uparser.md) ^0.2.4

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.9.1 (latest) — 2022-05-19
- 0.9.0 — 2022-05-19
- 0.8.0 — 2021-12-09
- 0.7.4 — 2021-07-27
- 0.7.3 — 2021-07-12
- 0.7.2 — 2021-07-03
- 0.7.1 — 2021-06-14
- 0.7.0 — 2021-06-14
- 0.6.3 — 2021-06-10
- 0.6.2 — 2021-05-28
- 0.6.1 — 2021-03-26
- 0.6.0 — 2021-03-26
- 0.5.0 — 2021-03-05
- 0.4.3 — 2021-02-27
- 0.4.2 — 2021-02-27
- … 7 more at https://npm.io/package/uhtml-ssr/versions

## README

# <em>µ</em>html-ssr

[![build status](https://github.com/WebReflection/uhtml-ssr/actions/workflows/node.js.yml/badge.svg)](https://github.com/WebReflection/uhtml-ssr/actions) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/uhtml-ssr/badge.svg?branch=main)](https://coveralls.io/github/WebReflection/uhtml-ssr?branch=main)

<sup>**Social Media Photo by [Nathan Dumlao](https://unsplash.com/@nate_dumlao) on [Unsplash](https://unsplash.com/)**</sup>

**[µhtml](https://github.com/WebReflection/uhtml#readme)** for Service Worker, Web Worker, NodeJS, and other *SSR* cases, based on [µcontent](https://github.com/WebReflection/ucontent#readme) logic, but without 3rd party tools (no minification, etc.).

This module can be used as drop-in replacement for *µhtml* components, but rendered *SSR*, or where there is no *DOM*.

This module also exports `uhtml-ssr/async` helpers to always resolve asynchronous interpolations.

```js
import {render, html, svg} from 'uhtml-ssr';

// render accepts a callback instead of a DOM node
// or a response object with a `res.write(content)` method.
render(String, html`<h1>Hello µhtml-ssr 👋</h1>`);
//  "<h1>Hello µhtml-ssr 👋</h1>"
```

Exports have feature parity with *µhtml*, and pretty much everything else works the same, except:

  * inline *DOM* events are not rendered, these are simply removed
  * `ref=${...}` attributes receives `null` as there's no `node` or `element` to pass around


## Isomorphic <em>µ</em>html Components

If you are using *CommonJS* you *could* use [require-overrides](https://github.com/WebReflection/require-overrides/#readme) module to fake `uhtml` as `uhtml-ssr`.

```js
// component.js
const {html} = require('uhtml');
module.exports = (name) => {
  return html`Hello ${name}`;
};

// index.js
const overrides = require('require-overrides');
overrides.set('uhtml', 'uhtml-ssr');

const {render} = require('uhtml-ssr');

const Component = require('./component.js');

console.log(render(String, Component('World')));
// "Hello World"
```

---
_Source: https://npm.io/package/uhtml-ssr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
