Overview
Shamela can be used in browsers with automatic CDN-hosted WASM files, or you can use the lightweight content-only export for processing pre-downloaded data.Full API (with sql.js)
For full database functionality in the browser, the library automatically uses a CDN-hosted WASM file:Custom CDN
You can specify a different CDN or self-hosted WASM file:Content-Only Export (Lightweight)
If you only need content processing utilities without database functionality, use theshamela/content export:
Available Exports from shamela/content
parseContentRobust- Parse HTML into structured lines preserving title spansmapPageCharacterContent- Normalize Arabic text with mapping rulessplitPageBodyFromFooter- Separate body from footnotesremoveArabicNumericPageMarkers- Remove page markersremoveTagsExceptSpan- Strip HTML except spanshtmlToMarkdown- Convert Shamela HTML to Markdown (title spans →##headers)normalizeHtml- Normalize hadeeth tags to standard spansnormalizeLineEndings- Normalize line endings to Unix-style (\n)stripHtmlTags- Strip all HTML tags from contentnormalizeTitleSpans- Handle consecutive title spans (merge, split, or hierarchy)moveContentAfterLineBreakIntoSpan- Move pre-title text into the spanconvertContentToMarkdown- Full pipeline: normalize spans → move pre-title text → convert to Markdown
Available Exports from shamela/transform
denormalizeBooks- Resolve relationships in MasterData to return rich book objects
Use Cases for Content-Only Export
Client-Side React/Next.js Components
Processing Pre-Downloaded Data
Bundled Environments
Avoid including sql.js in your bundle:Content Processing Examples
Parse HTML Content
Normalize Arabic Content
Split Body and Footnotes
Convert to Markdown
Normalize Consecutive Titles
Full Markdown Pipeline
Custom Character Mapping Rules
Extend default mapping rules for custom processing:TypeScript Support
Content utilities include full type definitions:Browser Fetch Configuration
For older browsers or custom fetch implementations:Bundle Size Comparison
CORS Considerations
When using the full API in browsers, ensure the Shamela API endpoints have appropriate CORS headers configured.Best Practices
CDN-hosted WASM is loaded automatically in browsers, but you can specify a custom URL if needed.
Next Steps
Content Processing
Deep dive into content processing utilities
Next.js Usage
Using content exports in Next.js client components