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

@chart-platform/server-renderer

v0.4.0

Published

Server-side SVG and PNG renderer for Chart Platform Library.

Readme

@chart-platform/server-renderer

Server-side SVG and PNG renderer for Chart Platform Library.

Renders a ChartDefinition from @chart-platform/core on the server — no browser, no DOM required. Outputs a static SVG string, a PNG buffer, or base64-encoded versions of either. Also exports ChartServerImage, an async React Server Component for Next.js App Router.

Installation

npm install @chart-platform/core @chart-platform/server-renderer

Exports

| Export | Description | |---|---| | renderToSVG() | Renders a chart to an SVG string | | renderToPNG() | Renders a chart to a PNG Buffer | | renderToSVGBase64() | Renders a chart to a base64-encoded SVG string | | renderToPNGBase64() | Renders a chart to a base64-encoded PNG string | | ChartServerImage | Async React Server Component — inline SVG |

Generate a PNG file

import { renderToPNG } from "@chart-platform/server-renderer";
import { writeFileSync } from "fs";
import type { ChartDefinition } from "@chart-platform/core";

const weeklyOrders: ChartDefinition = {
  type: "bar",
  title: "Weekly Orders",
  labels: ["Mon", "Tue", "Wed", "Thu", "Fri"],
  series: [{ id: "orders", label: "Orders", data: [34, 47, 29, 61, 55] }]
};

const png = await renderToPNG(weeklyOrders, { width: 800, height: 400, background: "#ffffff" });
writeFileSync("chart.png", png);

Generate an SVG file

import { renderToSVG } from "@chart-platform/server-renderer";

const svg = await renderToSVG(weeklyOrders, { width: 800, height: 400 });
writeFileSync("chart.svg", svg);

Serve a chart over HTTP (Express)

import express from "express";
import { renderToPNG } from "@chart-platform/server-renderer";

const app = express();

app.get("/chart.png", async (req, res) => {
  const png = await renderToPNG(weeklyOrders, { width: 800, height: 400, background: "#ffffff" });
  res.set("Content-Type", "image/png").send(png);
});

app.listen(3000);

Embed in an email or JSON API (base64)

import { renderToPNGBase64 } from "@chart-platform/server-renderer";

const base64 = await renderToPNGBase64(weeklyOrders, { width: 800, height: 400, background: "#ffffff" });

// Ready to embed in HTML
const html = `<img src="data:image/png;base64,${base64}" />`;

React Server Component — Next.js App Router

ChartServerImage is an async RSC that renders a chart as an inline SVG. No DOM, no JavaScript sent to the browser, no hydration.

import { ChartServerImage } from "@chart-platform/server-renderer";

export default async function Page() {
  return (
    <ChartServerImage
      definition={weeklyOrders}
      width={800}
      height={400}
      theme="dark"
    />
  );
}

ChartServerImage accepts the same definition and theme props as ChartRenderer from @chart-platform/react-renderer — so one chart definition works in all environments:

weeklyOrders ──→ <ChartRenderer />       (client, interactive)
             ──→ renderToPNG()           (Node.js, PNG file)
             ──→ <ChartServerImage />    (Next.js RSC, inline SVG)

ChartServerImage props

| Prop | Type | Default | Description | |---|---|---|---| | definition | ChartDefinition | required | Chart to render | | width | number | 800 | Output width in pixels | | height | number | 400 | Output height in pixels | | theme | ThemeName \| ChartTheme | "light" | Built-in theme or custom theme object | | background | string | — | Background colour override | | aria-label | string | chart title | Accessible label |

Theming

All render functions and ChartServerImage accept an optional theme parameter:

// Built-in theme by name
await renderToSVG(weeklyOrders, { width: 800, height: 400 }, "dark");
await renderToPNG(weeklyOrders, { width: 800, height: 400 }, "minimal");

// Custom theme object — unset fields fall back to light theme defaults
import type { ChartTheme } from "@chart-platform/core";

const customTheme: ChartTheme = {
  colors: ["#7c3aed", "#db2777", "#ea580c"],
  backgroundColor: "#1e1b2e",
  textColor: "#c4b5fd"
};

await renderToSVG(weeklyOrders, { width: 800, height: 400 }, customTheme);

| Theme | Background | Palette | |---|---|---| | "light" (default) | white | blue-toned | | "dark" | #1e2030 | vibrant | | "minimal" | white | monochrome |

Export options

| Field | Type | Required | Description | |---|---|---|---| | width | number | ✅ | Output width in pixels | | height | number | ✅ | Output height in pixels | | background | string | — | Background colour (overrides theme) |

Requirements

  • Node.js 22 or newer

Related packages

License

MIT