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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-ebookjs

v0.0.5

Published

A minimal, unstyled React component library for rendering and interacting with ebooks in web applications.

Readme

react-ebook

NPM

A minimal, unstyled React component library for rendering and interacting with ebooks in web applications.

Overview

react-ebook provides React components and utilities for displaying and navigating ebooks in various formats (EPUB, FB2, Comic Books) in web applications. It is built on top of foliate-js, the JavaScript library that powers the Foliate ebook reader application.

Note: This package relies on foliate-js, which is currently in development and not yet considered stable. APIs may change in future versions.

Features

  • Render ebooks in EPUB, FB2, and Comic Book formats
  • Paginated or scrolled reading modes
  • Navigation controls (next/previous page)
  • Table of contents navigation
  • Search functionality
  • Customizable text display (font size, line spacing, justification, hyphenation)
  • Progress tracking

Installation

npm install react-ebookjs

Usage

import { useState } from 'react';
import { 
  Reader, 
  ReaderContent, 
  ReaderNext, 
  ReaderPrevious, 
  loadEPUB 
} from 'react-ebookjs';

function EbookReader() {
  const [book, setBook] = useState(null);
  const [progress, setProgress] = useState(0);

  const handleFileChange = async (e) => {
    const file = e.target.files[0];
    if (file) {
      const loadedBook = await loadEPUB(file);
      setBook(loadedBook);
    }
  };

  if (!book) {
    return (
      <div>
        <h2>Select an ebook to read</h2>
        <input type="file" accept=".epub" onChange={handleFileChange} />
      </div>
    );
  }

  return (
    <Reader 
      book={book} 
      progress={progress}
      onProgressChange={setProgress}
    >
      <div style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
        <div style={{ flex: 1, overflow: 'hidden' }}>
          <ReaderContent 
            fontSize={16}
            lineSpacing={1.5}
            justify={true}
            hyphenate={true}
            flow="paginated"
          />
        </div>
        <div style={{ display: 'flex', justifyContent: 'space-between', padding: '1rem' }}>
          <ReaderPrevious>Previous</ReaderPrevious>
          <div>{Math.round(progress * 100)}%</div>
          <ReaderNext>Next</ReaderNext>
        </div>
      </div>
    </Reader>
  );
}

Philosophy

react-ebook is intentionally designed to be minimal and unstyled, focusing on functionality rather than appearance. This gives you complete control over the styling and integration with your application's design system.

The library provides the core functionality needed to render and interact with ebooks, while leaving the UI implementation details to you. This approach makes it highly flexible and adaptable to different design requirements.

Supported Formats

  • EPUB (2 and 3)
  • FB2
  • Comic Books (CBZ, CBR)

API

Components

  • Reader: The main component that provides the reading context
  • ReaderContent: Renders the book content
  • ReaderNext: Button component to navigate to the next page
  • ReaderPrevious: Button component to navigate to the previous page

Hooks

  • useBookNavigator: Hook for programmatic navigation
  • useSearch: Hook for searching within the book

Loaders

  • loadEPUB: Load an EPUB file
  • loadFB2: Load an FB2 file
  • loadComicBook: Load a comic book file (CBZ, CBR)

Credits

This library is built on top of foliate-js, created by John Factotum. Foliate-js is the JavaScript library that powers the Foliate ebook reader application.

License

MIT