# react-epub-search

> An epub-reader for React integrated with search powered by ePubJS

Latest version **1.0.1** (published 2023-05-09) · 0 weekly downloads

## Install

```sh
npm install react-epub-search
pnpm add react-epub-search
yarn add react-epub-search
bun add react-epub-search
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-05-09 |
| First published | 2023-05-09 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 67 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Riya Lohia |
| Maintainers | riyalohia |
| Keywords | react, epub, epubJS, react reader |

## Links

- npm: https://www.npmjs.com/package/react-epub-search
- Repository: https://github.com/riyalohia/react-epub-search
- Homepage: https://github.com/riyalohia/react-epub-search#readme
- Issues: https://github.com/riyalohia/react-epub-search/issues
- npm.io page: https://npm.io/package/react-epub-search

## Dependencies (1)

- [epubjs](https://npm.io/package/epubjs.md) ^0.3.92

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-05-09
- 1.0.0 — 2023-05-09

## README

# React Epub Search

An ePub-reader for react intergrated with search powered by EpubJS #react #epubjs #webpack #babel #standardjs

[Inspiration](https://github.com/gerhardsletten/react-reader)

## React wrapper for EpubJS

React Reader is a react-wrapper for [epub.js](https://github.com/futurepress/epub.js).

## About

[epub.js](https://github.com/futurepress/epub.js) is a great library and this is a wrapper for it intergated with search. This wrapper makes it easy to use in a React-app.

This package publish 4 named exports:

- EpubReader - Most used, a basic epub-reader to embed into your webapp
- EpubView - Underlaying epub-canvas (wrapper for epub.js iframe)

## Basic usage

`npm install react-epub-search --save`

```js
import React, { useState } from 'react'
import { EpubReader } from 'react-epub-search'

const App = () => {
  // And your own state logic to persist state
  const [location, setLocation] = useState(null)
  const locationChanged = epubcifi => {
    // epubcifi is a internal string used by epubjs to point to a location in an epub. It looks like this: epubcfi(/6/6[titlepage]!/4/2/12[pgepubid00003]/3:0)
    setLocation(epubcifi)
  }
  return (
    <div style={{ height: '100vh' }}>
      <EpubReader
        location={location}
        locationChanged={locationChanged}
        url="https://react-reader.metabits.no/files/alice.epub"
      />
    </div>
  )
}

export default App
```
### Handling Search Results

```js
const App = () => {
  // And your own state logic to persist state
  const [location, setLocation] = useState(null)
  const locationChanged = epubcifi => {
    setLocation(epubcifi)
  }
  const onChangeSearchResults = (result) => console.log(results);

  return (
    <div style={{ height: '100vh' }}>
      <EpubReader
        location={location}
        locationChanged={locationChanged}
        onChangeSearchResults={onChangeSearchResults}
        url="https://react-reader.metabits.no/files/alice.epub"
      />
    </div>
  )
}
```

Other Functionalities:
1. Theme (Light/Dark)
2. Theme Change (Color and Font Size)
3. Reset Reader (Used for toggle theme) (Bug of EpubJS)
4. navigationChangehandler (Used for right-left arrow keys)
5. Image Click

---
_Source: https://npm.io/package/react-epub-search · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
