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

@perspective-dev/react

v5.5.1

Published

React component wrappers for `<perspective-viewer>`

Readme

@perspective-dev/react

npm

React bindings for Perspective, an interactive analytics and data visualization component for large, real-time and streaming datasets. This package wraps the <perspective-viewer> Custom Element in an idiomatic, declarative React component, <PerspectiveViewer>, which manages the element's imperative load()/restore()/delete() lifecycle for you.

Installation

npm install @perspective-dev/react

@perspective-dev/client and @perspective-dev/viewer are installed as dependencies, but you'll also want at least one plugin package for the visualizations themselves:

npm install @perspective-dev/viewer-datagrid @perspective-dev/viewer-charts

Setup

Perspective's engine and UI are WebAssembly binaries which must be initialized once, before the first <PerspectiveViewer> renders. Plugins register themselves via import side effects. See the User Guide's bundling section for bundler configuration details.

import perspective from "@perspective-dev/client";
import perspective_viewer from "@perspective-dev/viewer";
import "@perspective-dev/viewer-datagrid";
import "@perspective-dev/viewer-charts";
import "@perspective-dev/viewer/dist/css/themes.css";

import SERVER_WASM from "@perspective-dev/server/dist/wasm/perspective-server.wasm";
import CLIENT_WASM from "@perspective-dev/viewer/dist/wasm/perspective-viewer.wasm";

await Promise.all([
    perspective.init_server(fetch(SERVER_WASM)),
    perspective_viewer.init_client(fetch(CLIENT_WASM)),
]);

Usage

Create a Table (here in a Web Worker Client) and pass it — or a Promise of it — to <PerspectiveViewer>:

import * as React from "react";
import { PerspectiveViewer } from "@perspective-dev/react";

const WORKER = await perspective.worker();

const TABLE = WORKER.table(
    fetch("superstore.lz4.arrow").then((resp) => resp.arrayBuffer()),
    { name: "superstore" },
);

const App: React.FC = () => (
    <PerspectiveViewer
        client={TABLE}
        config={{ group_by: ["State"], plugin: "Y Bar" }}
    />
);

Props

| Prop | Type | Description | | :--------------- | :------------------------------------------------------------ | :-------------------------------------------------------------- | | client | Client \| Table \| Promise<Client> \| Promise<Table> | Data source. When undefined, the viewer eject()s. | | config | ViewerConfigUpdate \| WorkspaceConfigUpdate | Declarative viewer state, applied via restore(). | | onConfigUpdate | (config: ViewerConfigUpdate) => void | Called when the user reconfigures the viewer through its UI. | | onClick | (detail: PerspectiveClickEventDetail) => void | Called when the user clicks a datapoint. | | onSelect | (detail: PerspectiveSelectEventDetail) => void | Called when the user selects (or deselects) a datapoint or row. |

A subset of standard HTML attributes — className, id, style, hidden, slot, tabIndex and title — is forwarded to the underlying element.

client

The viewer's data source, forwarded to viewer.load() whenever it changes:

  • A Table (or Promise<Table>) displays that table directly.
  • A Client (e.g. from perspective.worker() or a WebSocket connection to a remote server) connects the viewer to every table hosted by that client; the table each panel displays is chosen by config or interactively by the user.
  • undefined ejects the viewer, returning it to an unloaded state without unmounting it.

The component does not take ownership of the Table — delete it yourself when it is no longer needed (e.g. table.delete({ lazy: true })).

config

Declarative viewer state — group-bys, splits, filters, sorts, expressions, plugin and plugin config — applied with restore() whenever it (or client) changes. A config with a panels property is treated as a multi-panel workspace layout and applied with restoreWorkspace() instead. Configs are compared structurally, so passing a fresh-but-equal object literal on each render does not re-apply.

Combine config with onConfigUpdate to make the viewer a controlled component — store the user's latest configuration in state (or persist it) and pass it back down:

const App: React.FC = () => {
    const [config, setConfig] = React.useState<pspViewer.ViewerConfigUpdate>({
        group_by: ["Category"],
    });

    return (
        <PerspectiveViewer
            client={TABLE}
            config={config}
            onConfigUpdate={setConfig}
        />
    );
};

Lifecycle

On unmount, the component calls the element's delete() method, freeing the viewer's WebAssembly resources. Tables and clients are created outside the component and are yours to manage; a Table passed as client survives unmount and can be shown again by a later mount.

See also