Skip to content

Introduction ​

vue-book-reader is a Vue wrapper around foliate-js for rendering e-books in the browser. It supports EPUB, MOBI, KF8 (AZW3), FB2, CBZ, TXT, and PDF (experimental; requires PDF.js).

Installation ​

sh
npm install vue-book-reader
sh
pnpm add vue-book-reader

Basic usage ​

Import and use the component in your Vue application:

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

Distribution files ​

Module formatFile
UMD (direct browser usage)vue-book-reader.umd.js
ES module (bundlers)vue-book-reader.es.js

VueReader API ​

Props ​

NameDescriptionTypeDefault
urlURL or local file for the book.string | FileRequired
titleTitle displayed above the reader. If omitted, the book metadata title is used.string''
showTocWhether to show the table-of-contents control.booleantrue
getRenditionCalled when the underlying foliate view is ready.(view) => void—
BookView propsAll BookView props can also be passed to VueReader.——

Slots ​

NameDescription
titleCustom content for the title area.
BookView slotsAll BookView slots are also available.

Exposed methods ​

NameDescriptionType
nextPageGo to the next page.() => void
prevPageGo to the previous page.() => void
setLocationGo to a specific location.(href: string) => void

BookView API ​

Props ​

NameDescriptionTypeDefault
urlURL or local file for the book.string | FileRequired
locationInitial or updated reading location.string | number—
initOptionOptions passed to the foliate view during initialization.object—
tocChangedCalled with the book's table of contents after loading.(toc: object[]) => void—
getRenditionCalled when the underlying foliate view is ready.(view) => void—

Events ​

NameDescriptionPayload
update:locationEmitted whenever the reading location changes.Relocation details from foliate-js

Slots ​

NameDescription
loadingViewContent displayed while the book is loading.
errorViewContent displayed if the book fails to load.

Exposed methods ​

NameDescriptionType
nextPageGo to the next page.() => void
prevPageGo to the previous page.() => void
setLocationGo to a specific location.(href: string) => void