← Back to Home

Audio Reader Reference

A beautiful audio player for MP3 and M4B formats with track switching.

Usage Example

import dynamic from "next/dynamic";

const AudioReader = dynamic(
  () => import("epub-pdf-viewer").then((mod) => mod.AudioReader),
  { ssr: false }
);

export default function MyAudioBook() {
  const tracks = [
    { title: "Chapter 1", author: "Author Name", url: "/audio1.mp3" },
    { title: "Chapter 2", author: "Author Name", url: "/audio2.m4b" }
  ];

  return (
    <AudioReader
      tracks={tracks}
      bookName="My Audio Book"
      themeColor="#10b981"
      toast={toast} // Optional for notifications
    />
  );
}

Interactive Demo

Props API Reference

Prop NameTypeRequiredDescription
tracksArrayYesArray of objects `title, author, url` for the playlist.
activeTrackIndexnumberNoThe index of the track to play. Default: 0.
onTrackSelectfunctionNoCallback when track changes `(track, index) => void`.
bookNamestringNoThe overall title of the audiobook.
themeColorstringNoHex color for accents and UI elements.
coverUrlstringNoCover image URL for the vinyl disc art.
toastobjectNoToast notification object (e.g. `sonner`).