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

@smazeeapps/file-viewer

v1.0.7

Published

Flexible React file viewer for rendering PDFs, Office documents, Markdown, CSV, code, and more in the browser.

Downloads

536

Readme

@smazeeapps/file-viewer

React file viewer for rendering common document, text, code, and image formats in the browser with a single component.

The package is built for browser-based preview workflows where you want one entry point, lazy-loaded format-specific viewers, and a consistent UI for file inspection.

Features

  • Single FileViewer component API
  • Supports remote URLs and local File objects
  • Lazy-loads heavy viewers by file type
  • Search UI opened with Ctrl+F / Cmd+F
  • Optional programmatic search via searchMode
  • Emits text-selection metadata through onTextSelect
  • Light and dark themes
  • TypeScript types included

Supported file types

The viewer detects format from fileName:

  • pdf
  • docx
  • ppt / pptx
  • txt / log
  • code files: js, ts, tsx, jsx, py, java, cpp, c, go, rs, php, rb, css, scss, sql, yaml, yml, xml
  • html / htm
  • md / markdown
  • csv
  • xls / xlsx
  • json
  • images: png, jpg, jpeg, gif, webp, svg, bmp, ico

Unknown extensions fall back to an unsupported-file state instead of throwing.

Install

npm install @smazeeapps/file-viewer react react-dom

Basic usage

import { FileViewer } from "@smazeeapps/file-viewer";

export function Example() {
  return (
    <FileViewer
      src="https://example.com/files/report.pdf"
      fileName="report.pdf"
      height="800px"
      theme="light"
    />
  );
}

With local uploads

import { useState } from "react";
import { FileViewer } from "@smazeeapps/file-viewer";

export function UploadPreview() {
  const [file, setFile] = useState<File | null>(null);

  return (
    <div>
      <input
        type="file"
        onChange={(event) => setFile(event.target.files?.[0] ?? null)}
      />

      {file ? (
        <FileViewer
          src={file}
          fileName={file.name}
          fileId={`upload:${file.name}`}
          height="70vh"
          theme="dark"
        />
      ) : null}
    </div>
  );
}

API

FileViewer

type FileViewerTheme = "light" | "dark";

type FileViewerSearchMode = {
  text: string;
};

type TextSelectionPayload = {
  file_name: string;
  file_id?: string;
  text: string;
  page_number?: number;
  line_number?: string;
};

type FileViewerProps = {
  src: string | File;
  fileName: string;
  fileId?: string;
  height?: string;
  theme?: FileViewerTheme;
  searchMode?: FileViewerSearchMode;
  onTextSelect?: (payload: TextSelectionPayload) => void;
};

Props

| Prop | Type | Required | Notes | | --- | --- | --- | --- | | src | string \| File | yes | Remote file URL or browser File object | | fileName | string | yes | Used for file-type detection | | fileId | string | no | Passed back in selection events | | height | string | no | Defaults to "800px" | | theme | "light" \| "dark" | no | Defaults to "light" | | searchMode | { text: string } | no | Opens search, applies the text, and jumps to the first match | | onTextSelect | (payload) => void | no | Fired when text is selected inside supported viewers |

Exports

import {
  FileViewer,
  detectFileType,
  type FileViewerProps,
  type FileViewerSearchMode,
  type FileViewerTheme,
  type FileKind,
  type TextSelectionPayload,
} from "@smazeeapps/file-viewer";

Viewer behavior

  • PDF viewer supports single-page, continuous, and two-column reading modes, and defaults to single-page mode.
  • HTML, Markdown, and CSV viewers provide preview/source-style workflows.
  • JSON files render as a tree, and invalid JSON shows parser errors with line context.
  • Code files use Prism-based syntax highlighting with line numbers.
  • Excel files render worksheet data in a spreadsheet-like table.
  • DOCX and PPTX files are rendered in-browser without requiring external services.

Search and text selection

FileViewer keeps the search UI hidden until the user presses Ctrl+F or Cmd+F while the viewer is focused. Search highlights matches inside the rendered viewer content where the DOM is searchable.

You can also drive search from the parent component:

<FileViewer
  src={file}
  fileName={file.name}
  searchMode={{ text: "invoice total" }}
/>

When searchMode is provided, the viewer highlights matches and scrolls to the first result without opening the search bar. The visible search UI still only appears through Ctrl+F / Cmd+F. For PDFs, the viewer keeps the user’s selected PDF view mode and moves to the first matching page.

If you provide onTextSelect, the component emits a payload like:

{
  "file_name": "example.ts",
  "file_id": "sample:example.ts",
  "text": "selected text",
  "page_number": 2,
  "line_number": "14-16"
}

page_number and line_number are included when the active viewer can resolve them.

Development

Package scripts

npm run build
npm run dev
npm run typecheck

Example app

The repository includes a separate example workspace in example with sample files and tests.

cd example
npm install
npm run demo

Useful example scripts:

  • npm test
  • npm run test:watch
  • npm run typecheck

Notes

  • This package is intended for browser environments. Browser-only APIs are used inside effects and lazy-loaded viewers.
  • PDF rendering depends on pdfjs-dist and configures its worker at runtime.
  • Remote file URLs must be fetchable by the browser running your app.

Changelog

1.0.2 (2026-05-09)

  • Added this changelog section to the README.
  • Improved FileViewer and PDF viewer layout: clearer height handling and overflow behavior for embedded previews.

1.0.1

  • Published under the scoped name @smazeeapps/file-viewer (rebrand from @edithly/file-viewer).
  • Updated README, example app, and tests to use the new package name and install path.

1.0.0

  • Initial public release: FileViewer with lazy-loaded format viewers, search (Ctrl+F / Cmd+F and searchMode), onTextSelect, and light/dark themes.

License

MIT