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

@zerohive/hive-viewer

v1.0.1

Published

You can use the ModalViewer component to display any content (such as DocumentViewer) in a modal dialog. Here is a simple example:

Readme

ModalViewer Usage Example

You can use the ModalViewer component to display any content (such as DocumentViewer) in a modal dialog. Here is a simple example:

import React, { useState } from 'react';
import { ModalViewer } from './src/components/ModalViewer';
import { DocumentViewer } from './src/components/DocumentViewer';
import './src/components/ModalViewer.css';

export default function App() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <button onClick={() => setOpen(true)}>Open Document Modal</button>
      <ModalViewer open={open} onClose={() => setOpen(false)}>
        <DocumentViewer url="/path/to/document.pdf" />
      </ModalViewer>
    </>
  );
}

Props:

  • open (boolean): Whether the modal is visible.
  • onClose (function): Called when the modal requests to close (overlay click, ESC, close button).
  • children (ReactNode): Content to display inside the modal.
  • ariaLabel (optional string): Accessibility label for the modal dialog.

Styling:

Import ModalViewer.css for default modal styles, or customize as needed.

@zerohive/hive-viewer

A self-hostable, browser-first document viewer/editor for React and Next.js.

Install

npm i @zerohive/hive-viewer

Import styles once in your app:

import "@zerohive/hive-viewer/styles.css";

Usage

Basic Usage

import { DocumentViewer } from "@zerohive/hive-viewer";

export default function Page() {
  return (
    <DocumentViewer
      mode="edit"
      fileUrl="https://example.com/my.pdf"
      fileName="my.pdf"
      fileType="pdf"
      allowSigning
      onSignRequest={async () => ({
        signatureImageUrl: "https://.../sig.png",
        signedBy: "Jane Doe",
        dateSigned: new Date().toISOString(),
        comment: "Approved",
      })}
      onSave={(b64, meta) => {
        /* persist */
      }}
    />
  );
}

Using in a Modal (Recommended)

Most consumers use the viewer in a modal dialog. Here is a recommended pattern:

import React, { useState } from "react";
import { DocumentViewer } from "@zerohive/hive-viewer";

function ModalDocViewer({ open, onClose, fileUrl, fileName, fileType }) {
  if (!open) return null;
  return (
    <div
      style={{
        position: "fixed",
        inset: 0,
        background: "rgba(0,0,0,0.45)",
        zIndex: 1000,
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <div
        style={{
          background: "#fff",
          borderRadius: 16,
          maxWidth: "90vw",
          maxHeight: "90vh",
          overflow: "auto",
          position: "relative",
          padding: 0,
          boxShadow: "0 8px 32px rgba(0,0,0,0.25)",
        }}
      >
        <button
          onClick={onClose}
          aria-label="Close"
          style={{
            position: "absolute",
            top: 12,
            right: 16,
            background: "none",
            border: "none",
            fontSize: "2rem",
            color: "#888",
            cursor: "pointer",
            zIndex: 1,
          }}
        >
          ×
        </button>
        <DocumentViewer
          mode="view"
          fileUrl={fileUrl}
          fileName={fileName}
          fileType={fileType}
        />
      </div>
    </div>
  );
}

// Usage example:
export default function Example() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <button onClick={() => setOpen(true)}>Open Document</button>
      <ModalDocViewer
        open={open}
        onClose={() => setOpen(false)}
        fileUrl="https://example.com/my.pdf"
        fileName="my.pdf"
        fileType="pdf"
      />
    </>
  );
}

Signing Workflow (decoupled)

  • If allowSigning={true}, the toolbar shows Sign Document.
  • Clicking it calls onSignRequest() (parent handles biometric/e-signature/KYC/etc.).
  • The returned Signature is immediately displayed:
    • view/edit: signatures appear in the right signature panel and can be placed onto the page by clicking Place signature.
    • create: signatures are appended to the end of the document (no right panel).

Progressive loading and caching

  • fileUrl loading uses streaming where available (fetch + ReadableStream).
  • For PDFs, pdfjs is configured with rangeChunkSize so rendering can start before the full file downloads.
  • In fileUrl mode, the package caches the ArrayBuffer in-memory during the session to avoid re-fetching when switching layouts/modes.

Security

  • Markdown/HTML content is sanitized via DOMPurify before rendering.

Props

See src/types.ts for full types.