Skip to content

Feature Request: EPUB export support #2972

@gengjiawen

Description

@gengjiawen

What problem will this feature address?

Fumadocs currently only supports web-based output (server-rendered pages and static sites). There is no way to export documentation as an EPUB file for offline reading on e-readers, mobile devices, or for distribution as a self-contained ebook.

This is a common need for documentation projects that want to provide offline-friendly formats. Users who need EPUB output today must manually set up external toolchains (e.g., Pandoc) to convert their MDX/Markdown source files, losing fumadocs-specific features (admonitions, code tabs, structured TOC, etc.) in the process.

Describe the solution you'd like

Add an EPUB export capability, ideally as a new package (e.g., fumadocs-epub) or a CLI command (e.g., fumadocs export --format epub). The feature should:

  1. Leverage the existing content pipeline -- Reuse fumadocs-core's Source API and page tree to resolve document structure, ordering, and metadata, rather than re-parsing raw files from scratch.
  2. Render MDX to static HTML for EPUB chapters -- Compile each MDX page into a self-contained HTML fragment (with inlined or embedded assets), stripping interactive/client-side components that don't make
    sense in an ebook context (e.g., search, tabs could be flattened, API playground removed).
  3. Generate a valid EPUB 3 file -- Use a JavaScript EPUB library (such as https://www.npmjs.com/package/epub-gen-memory or https://www.npmjs.com/package/nodepub) to assemble the final .epub file natively in Node.js, without requiring external system dependencies like Calibre. This is a deliberate improvement over GitBook's legacy approach, which shelled out to Calibre's ebook-convert CLI -- an external
    dependency that was difficult to install in CI environments and added friction for users. downside is that the eco is not very mature.
  4. Map the page tree to EPUB structure:
    - Use the fumadocs page tree (from loader()) as the EPUB's table of contents / navigation document (NCX/nav).
    - Preserve heading hierarchy (up to 3 levels) in the EPUB TOC.
    - Use frontmatter metadata (title, description) for EPUB chapter metadata.
  5. Handle assets properly:
    - Inline or embed images referenced in documentation pages.
    - Apply a minimal, readable CSS stylesheet suitable for e-readers.
    - Support a configurable cover image.
  6. Support configuration via fumadocs.config or CLI flags:
    - Book metadata: title, author, description, language, publisher, isbn, cover
    - Page filtering: ability to include/exclude specific pages or folders
    - Output path

Describe alternatives you've considered

  1. External Calibre-based pipeline (GitBook's approach): Shell out to ebook-convert after generating HTML. Downside: requires users to install Calibre system-wide, which is heavy (~200MB) and difficult to set
    up in CI/Docker environments.
  2. Pandoc-based pipeline: Use Pandoc to convert Markdown → EPUB. Downside: also an external system dependency; loses fumadocs-specific MDX features (admonitions, code tabs, custom components); requires
    maintaining a separate Pandoc template.
  3. User-land script: Users write their own export script using the Source API. Downside: significant effort per project, no standardized approach, each user reinvents the wheel.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR welcomeFeature Request approvedenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions