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

@unovis/ssr

v1.7.0-mcp.2

Published

Server-side rendering for Unovis: render charts to standalone SVG and PNG in Node — no browser, no remote services

Readme

@unovis/ssr

Server-side rendering for Unovis: render charts to standalone SVG and PNG in Node — no browser, no remote services, your data never leaves the machine.

Unovis is browser-first: it builds SVG in a live DOM with D3, measures text with canvas, reads its theme from CSS custom properties and schedules rendering through requestAnimationFrame. This package provides exactly that environment headlessly (jsdom plus a shim layer), and one primitive on top of it.

Render a chart

import { renderToSvg } from '@unovis/ssr'

const { svg, width, height, warnings } = await renderToSvg(
  { width: 800, height: 400, theme: 'dark', title: 'Revenue' },
  (ctx) => {
    const line = new ctx.unovis.Line<{ x: number; y: number }>({ x: d => d.x, y: d => d.y, duration: 0 })
    return new ctx.unovis.XYContainer(ctx.container, {
      components: [line],
      xAxis: new ctx.unovis.Axis({ duration: 0 }),
      yAxis: new ctx.unovis.Axis({ duration: 0 }),
      width: ctx.width,
      height: ctx.height,
      duration: 0,
      onRenderComplete: ctx.onRenderComplete,
    }, data)
  }
)

Any hand-built Unovis chart works — the builder receives the library (ctx.unovis), a container element, and the completion hook to wire into the container config. Pass duration: 0 everywhere so rendering is synchronous. The result is a standalone document: no CSS classes, no custom properties, no external references — drop it in a README, an email, an <img>.

Components with asynchronous layouts (force-directed graphs) additionally wire ctx.onComponentReady and call ctx.requireComponentReady().

PNG

import { svgToPng, themeBackground } from '@unovis/ssr'

const png = await svgToPng(svg, { width: 800, scale: 2, background: themeBackground('dark') })

CSS background-color is not an SVG rendering attribute, so rasterizers need the background passed explicitly — themeBackground returns the Unovis theme color.

Fonts

Text measurement drives label trimming, wrapping and axis auto-margins, so the measuring font must match the declared font. On first render the pinned Inter release is downloaded once (SHA-256 verified, SIL OFL 1.1) into ~/.cache/unovis-ssr/fonts/ and registered with the canvas. Configuration:

| Variable | Meaning | |---|---| | UNOVIS_SSR_FONTS_DIR | Use your own directory of font files | | UNOVIS_SSR_NO_DOWNLOAD | Set to 1 to skip the download and use system fonts |

(The pre-extraction UNOVIS_MCP_* names still work.)

Building blocks

For consumers that host Unovis in their own jsdom — executing a browser bundle in tests, for example — the shims are exported individually: installBBoxPolyfills, installCanvasHook, installComputedStyle, RafQueue, defineElementSize, and getRenderEnv for the fully assembled environment.

Relationship to @unovis/mcp

@unovis/mcp — the MCP server that lets AI agents generate Unovis charts — is built on this package and re-exports its API. Use @unovis/ssr directly when you want headless rendering without the MCP surface: charts in CI, emails, PDFs, cron jobs. Full documentation of the architecture lives in the MCP docs.

Requirements

Node.js ≥ 20. Native dependencies (@napi-rs/canvas, @resvg/resvg-js) ship prebuilt — no compile step.