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

@openkova/core

v0.3.2

Published

HTML to image/PDF engine powered by Puppeteer. Render snippets, local HTML files, or live URLs to PNG, JPEG, WebP, or PDF — with configurable viewport, full-page capture, and pluggable storage.

Readme

@openkova/core

Node.js library for HTML to image and PDF conversion. Powers a self-hosted screenshot API — render snippets, local HTML files, or live URLs to pixel-accurate PNG, JPEG, WebP, or PDF using headless Chromium. Configurable viewport, full-page capture, output format, and pluggable storage.

Website: openkova.dev · API docs · Docs · Blog

Install

npm install @openkova/core
# or
pnpm add @openkova/core
# or
bun add @openkova/core

@openkova/core uses puppeteer-core and expects a Chromium binary to be available. In most environments, install puppeteer as a dev dependency (it bundles its own Chrome) or set the CHROMIUM_PATH environment variable to point to a system-installed binary.

npm install -D puppeteer

Usage

Screenshot an HTML snippet

import { screenshotSnippet, createSession } from '@openkova/core';

const sessionId = createSession();
const imageId = await screenshotSnippet('<h1>Hello</h1>', sessionId, {
  viewport: { width: 1280, height: 800 },
  fullPage: false,
  format: 'png', // 'png' | 'jpeg' | 'webp' | 'pdf'
  onProgress: (msg) => console.log(msg),
});
// file saved to ./data/<sessionId>/<imageId>  (e.g. abc123.png)

Screenshot a URL

import { screenshotUrl, createSession } from '@openkova/core';

const sessionId = createSession();
const imageId = await screenshotUrl('https://example.com', sessionId, {
  viewport: { width: 1280, height: 800 },
  fullPage: true,
  format: 'webp',
});

Generate a PDF

import { screenshotSnippet, createSession } from '@openkova/core';

const sessionId = createSession();
const imageId = await screenshotSnippet(html, sessionId, {
  format: 'pdf',
});
// imageId will be something like abc123.pdf

Crawl a site and screenshot all pages

import { crawlUrl, screenshotUrl, createSession } from '@openkova/core';

const sessionId = createSession();
const urls = await crawlUrl('https://example.com', 1); // depth 1 = root + linked pages
for (const url of urls) {
  await screenshotUrl(url, sessionId, { format: 'jpeg' });
}

Custom storage

By default files are saved to ./data (overridable via OPENKOVA_STORAGE_PATH). Pass a custom StorageAdapter for full control:

import { createRenderer, LocalStorageAdapter } from '@openkova/core';

const storage = new LocalStorageAdapter('/tmp/screenshots');
const { screenshotSnippet, screenshotUrl } = createRenderer(storage);

The StorageAdapter interface lets you save to S3, a database, or anywhere else:

interface StorageAdapter {
  save(sessionId: string, imageId: string, data: Buffer): Promise<void>;
  get(sessionId: string, imageId: string): Promise<Buffer | null>;
  list(sessionId: string): Promise<string[]>;
  delete(sessionId: string, imageId: string): Promise<void>;
}

Note: imageId values include the file extension (e.g. "abc123.jpg"), so your adapter receives the full filename as the key.

API

screenshotSnippet(html, sessionId, options?)

Wraps the HTML string in a full document (with meta viewport) and renders it.

| Option | Type | Default | Description | |---|---|---|---| | viewport | { width, height } | 1280×800 | Browser viewport size | | fullPage | boolean | false | Capture full scrollable height | | format | 'png' \| 'jpeg' \| 'webp' \| 'pdf' | 'png' | Output file format | | onProgress | (msg: string) => void | — | Progress callback |

Returns the imageId string (includes extension, e.g. "abc123.jpg").

screenshotUrl(url, sessionId, options?)

Navigates to a live URL and renders it. Accepts the same options as screenshotSnippet.

Throws if url does not use http/https or if the host resolves to a private/loopback address (SSRF protection).

crawlUrl(rootUrl, depth?, onProgress?)

Fetches rootUrl, extracts same-origin <a href> links, and returns the full list of URLs to capture. depth can be 1 (root + its links) or 2 (follow links one level further). Results are capped at MAX_CRAWL_URLS (200) regardless of depth.

MAX_CRAWL_URLS

Exported constant (200). The maximum number of URLs crawlUrl will return in a single call.

createSession()

Returns a new unique session ID. Files captured under the same session ID are grouped together.

createRenderer(storage)

Returns { screenshotSnippet, screenshotUrl } bound to a custom storage adapter.

Output formats

| Format | Notes | |---|---| | png | Lossless, default | | jpeg | Lossy, quality 85, smaller file size | | webp | Lossy, quality 85, best compression | | pdf | Uses Puppeteer's page.pdf() with printBackground: true |

Environment variables

| Variable | Default | Description | |---|---|---| | CHROMIUM_PATH | auto-detected | Path to Chrome/Chromium binary | | OPENKOVA_STORAGE_PATH | ./data | Root directory for saved files |

Changelog

See openkova.dev/changelog for the full release history.

License

MIT