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

plasmate

v0.4.0

Published

Agent-native headless browser. HTML in, Semantic Object Model out.

Downloads

420

Readme

plasmate

Agent-native headless browser for Node.js. HTML in, Semantic Object Model out.

Install

npm install plasmate

Requires the plasmate binary in your PATH:

curl -fsSL https://plasmate.app/install.sh | sh

Quick Start

import { Plasmate } from 'plasmate';

const browser = new Plasmate();

// Fetch a page as a structured Semantic Object Model
const som = await browser.fetchPage('https://news.ycombinator.com');
console.log(`${som.title}: ${som.regions.length} regions`);

// Extract clean text only
const text = await browser.extractText('https://example.com');
console.log(text);

// Interactive browsing
const session = await browser.openPage('https://example.com');
console.log(session.sessionId, session.som.title);

const title = await browser.evaluate(session.sessionId, 'document.title');
console.log(title);

await browser.closePage(session.sessionId);

// Clean up
browser.close();

API

new Plasmate(options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | binary | string | "plasmate" | Path to the plasmate binary | | timeout | number | 30000 | Response timeout in milliseconds |

Stateless (one-shot)

  • som(url, options?) - Convenience alias for fetchPage, returns typed Som
  • fetchPage(url, options?) - Returns SOM JSON
  • extractText(url, options?) - Returns clean text

Stateful (interactive sessions)

  • openPage(url) - Returns { sessionId, som }
  • evaluate(sessionId, expression) - Run JS, get result
  • click(sessionId, elementId) - Click element, get updated SOM
  • closePage(sessionId) - Close session

Lifecycle

  • close() - Shut down the plasmate process

SOM Types

The SDK exports full TypeScript types matching the SOM Specification v1.0:

import type { Som, SomRegion, SomElement, SomMeta, StructuredData } from 'plasmate';
import type { RegionRole, ElementRole, SemanticHint, ElementAction } from 'plasmate';

Key types:

  • Som - Root document: som_version, url, title, lang, regions, meta, structured_data?
  • SomRegion - Semantic region with id, role (navigation, main, aside, header, footer, form, dialog, content), elements
  • SomElement - Element with id, role (link, button, text_input, etc.), text?, actions?, attrs?, children?, hints?
  • SomMeta - Metadata: html_bytes, som_bytes, element_count, interactive_count
  • StructuredData - Extracted JSON-LD, OpenGraph, Twitter Cards, meta tags, and links

Query Helpers

The SDK includes query helpers for searching and traversing SOM documents:

import {
  findByRole, findById, findByTag, findInteractive,
  findByText, flatElements, getTokenEstimate,
} from 'plasmate';

const browser = new Plasmate();
const som = await browser.som('https://example.com');

// Find the main content region
const [main] = findByRole(som, 'main');

// Look up an element by its stable ID
const el = findById(som, 'e5');

// Find all links
const links = findByTag(som, 'link');

// Get all interactive elements (those with actions)
const interactive = findInteractive(som);

// Search by visible text (case-insensitive)
const matches = findByText(som, 'sign in');

// Flatten all elements across all regions
const all = flatElements(som);

// Estimate token count
const tokens = getTokenEstimate(som);
console.log(`~${tokens} tokens`);

browser.close();

| Function | Returns | Description | |----------|---------|-------------| | findByRole(som, role) | SomRegion[] | Find regions by role | | findById(som, id) | SomElement \| undefined | Find element by stable ID | | findByTag(som, tag) | SomElement[] | Find elements by element role | | findInteractive(som) | SomElement[] | All elements with actions | | findByText(som, text) | SomElement[] | Case-insensitive text search | | flatElements(som) | SomElement[] | Flatten all elements | | getTokenEstimate(som) | number | Estimate token count (~4 bytes/token) |

How It Works

The SDK spawns plasmate mcp as a child process and communicates via JSON-RPC 2.0 over stdio. The plasmate binary handles HTML parsing, JavaScript execution (V8), and SOM compilation in Rust.

License

Apache-2.0