How to Integrate React Epub Reader with next js

Viewed 202

I am trying to integrate react epub reader with Next Js but getting one error and works well with react js, I need your help to integrate epub reader with next js

error

My code

import React from 'react';
import { ReactReader } from "react-reader";

export default function Home() {
  return (
    <div>
         <div style={{ position: "relative", height: "330px" }}>
<ReactReader
        url="./Boy without a name English.epub"
        title={"Alice in wonderland"}
        location={"epubcfi(/6/2[cover]!/6)"}
        locationChanged={epubcifi => console.log(epubcifi)}
      />
    </div>
  </div>
  )
}
1 Answers

The issue can be fixed by transpiling react-reader and epubjs modules (exported as ESM since a few months back).

For example, using next-transpile-modules in Next.js config:

// next.config.js
const withTM = require("next-transpile-modules")(["react-reader", "epubjs"]);

module.exports = withTM({/* custom config */});
Related