Skip to content

Introduction

an easy way to embed a ePub into your webapp

Installation

sh
npm i vue-reader
sh
pnpm add vue-reader

Basic Usage

And in your vue-component...

Vue 3
Vue 2
vue
<template>
  <div style='height: 100vh'>
    <vue-reader url='/vue-reader/files/啼笑因缘.epub'/>
  </div>
</template>
<script>
import { VueReader } from 'vue-reader'

export default {
  components: { VueReader }
}
</script>

Different Builds

ModuleFilename
UMD(for browsers)vue-reader.global-full.js
CommonJSvue-reader.cjs.js
ES Module(for bundlers)vue-reader.es.js

VueReader Attributes

NameDescriptionTypeDefault
urlbook url or arrayBufferstring/ArrayBuffer
titlethe title of the bookstring
showTocwhether to show the tocbooleantrue
backgroundColorbackgroundColor of readerstring#fff

VueReader Events

NameDescriptionType
progressbook url request progressfunction(percentage)

VueReader Slots

NameDescription
titleYou have access to title by slot

VueReader props passed to inner EpubView

EpubView Attributes

NameDescriptionTypeDefault
urlthe path or arrayBuffer of the bookstring/ArrayBuffer
locationset / update location of the epubstring/number
tocChangedwhen the reader has parsed the book you will receive an array of the chaptersfunction(toc)
epubInitOptionspass custom properties to the epub init function, see epub.jsobject
epubOptionspass custom properties to the epub rendition, see epub.js's book.renderTo functionobject
getRenditionwhen epubjs has rendered the epub-file you can get access to the epubjs-rendition object herefunction(rendition)

EpubView Events

NameDescriptionType
update:locationa function that receives the current location while user is reading. This function is called everytime the page changes, and also when it first renders.function(location)
selectwhen select textfunction(cfirange,contents)
keyPresswhen press the keyfunction(keyboardEvent)

EpubView Slots

NameDescription
loadingViewepub view loadingView

EpubView Exposes

NameDescriptionType
nextPagedisplay next pagefunction
prevPagedisplay previous pagefunction
setLocationSet the pagefunction(href)