foliate-js is a lightweight, dependency-free library that brings e-book rendering to any web application. It supports the most common e-book formats through a clean, modular API built on native ES modules — import only what you need.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/johnfactotum/foliate-js/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
Get a working e-book viewer running in minutes with the
<foliate-view> web component.Security
Learn how to safely render untrusted e-book content using Content Security Policy.
Core Concepts
Understand the book interface, renderer architecture, and EPUB CFI navigation.
API Reference
Explore the full API for the View element, book parsers, and utility modules.
Why foliate-js?
foliate-js powers the Foliate e-book reader app. It was designed to be small, modular, and not require any build steps — you can import the ES modules directly.Multi-format
EPUB, MOBI, KF8 (AZW3), FB2, CBZ, and experimental PDF support out of the box.
No dependencies
Pure JavaScript with zero hard dependencies. Zip and compression libraries are optional and vendored.
Modular
Each module is standalone. Use only the parsers and renderers your project needs.
Web Components
The main entry point is a native custom element (
<foliate-view>) — no framework required.Annotations
SVG-based overlay system for highlights, underlines, and custom annotation styles.
Full-text search
Built-in search across all sections using
Intl.Collator and Intl.Segmenter.Getting started
Clone or submodule the repository
Since there is no stable release yet, add foliate-js as a git submodule so you can track updates.
Supported formats
| Format | Module | Notes |
|---|---|---|
| EPUB 2 & 3 | epub.js | Full support including media overlays |
| MOBI | mobi.js | Decompresses all text at once |
| KF8 / AZW3 | mobi.js | Lazy decompression for performance |
| FictionBook 2 (FB2) | fb2.js | Including .fb2.zip archives |
| Comic Book Archive (CBZ) | comic-book.js | Fixed-layout rendering |
pdf.js | Experimental; requires PDF.js |
foliate-js is not yet stable. The API may change at any time. It is recommended to pin to a specific commit using a git submodule.