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

@magnet-js/ssr

v0.2.0

Published

Server-side rendering support for Magnet components.

Readme

@magnet/ssr

Lightweight server-side rendering support for Magnet components.

@magnet/ssr exports ssrWindow, a minimal implementation of MagnetWindow that renders Magnet components to plain HTML strings on the server. It provides lightweight server-side DOM implementations (SSRComment, SSRText, SSRElement) with just enough surface area for the rest of Magnet to operate.

Install

JSR

deno add jsr:@magnet/ssr

npm via JSR

npx jsr add @magnet/ssr

npm

npm install @magnet-js/ssr

Usage

import { ssrWindow } from "@magnet/ssr";
import { magnet } from "@magnet/ui";

const ctx = magnet({ window: ssrWindow /* signal API */ });
const element = ctx.html.div({ class: "greeting" }, "Hello");
console.log(element.toString());
// <div class="greeting">Hello</div>

If you need a full document, prepend <!DOCTYPE html> yourself:

const html = "<!DOCTYPE html>" + element.toString();

Namespaced attributes

Consumers specify namespaced attributes by wrapping the value with a namespace URI key from @magnet/ui:

import { nsAttr } from "@magnet/ui";

const xlink = nsAttr("http://www.w3.org/1999/xlink");

const element = ctx.html.svg({
  "x:href": xlink("/icon.svg"),
});

The consumer is responsible for choosing a prefixed key such as "x:href" in the attributes object. nsAttr attaches the namespace URI to the value. Magnet passes both the prefixed key and the namespace URI to setAttributeNS, so ssr.ts stores the attribute under the full key name.

Design trade-offs

The implementation is intentionally minimal and fast:

  • No attribute value escaping. Consumers are expected to provide well-formed attribute values.
  • Empty string attributes render as boolean attributes. For example, disabled="" is emitted as disabled.
  • Namespaced attributes are stored by their full key. The consumer chooses a prefixed key such as "x:href"; nsAttr attaches the namespace URI to the value, and Magnet passes both the key and the URI to setAttributeNS.
  • Shadow DOM is not supported. attachShadow is stubbed out. Magnet checks browser() before attaching shadow roots, so this path is not exercised during SSR.
  • No attribute name validation. Invalid or unsafe attribute names are emitted as-is.
  • Text nodes escape &, <, and > only. This is sufficient for plain text content; consumers handling richer text should preprocess it.

License

MIT © 2026 Fernando G. Vilar.