For non-bundled Node.js environments, the WASM file is auto-detected:
import { configure, getBook } from 'shamela';// Configure API credentialsconfigure({ apiKey: process.env.SHAMELA_API_KEY, booksEndpoint: process.env.SHAMELA_BOOKS_ENDPOINT, masterPatchEndpoint: process.env.SHAMELA_MASTER_ENDPOINT, // sqlJsWasmUrl is auto-detected in standard Node.js});
Download a complete book with all pages and titles:
import { getBook } from 'shamela';const book = await getBook(26592);console.log(`Downloaded book with ${book.pages.length} pages`);console.log(`Table of contents has ${book.titles.length} entries`);// Access page contentconst firstPage = book.pages[0];console.log(firstPage.content);
For client-side or lightweight use cases where you only need content utilities without database functionality, use the shamela/content export:
import { mapPageCharacterContent, splitPageBodyFromFooter, removeTagsExceptSpan, htmlToMarkdown,} from 'shamela/content';// Process content without loading sql.js (~1.5KB gzipped vs ~900KB)const normalized = mapPageCharacterContent(rawContent);const cleaned = removeTagsExceptSpan(normalized);const [body, footnotes] = splitPageBodyFromFooter(cleaned);const markdown = htmlToMarkdown(body);
The shamela/content export is ideal for React/Next.js client components where you want to process pre-downloaded book data without loading the full sql.js WASM bundle.