Skip to main content
API Key Required: You need a valid Shamela API key before proceeding.Request your API key by emailing mail@shamela.ws.

Configuration

Before using the library, configure it with your API credentials and endpoint URLs.

Standard Node.js

For non-bundled Node.js environments, the WASM file is auto-detected:

Next.js / Bundled Environments

For Next.js, webpack, Turbopack, and other bundlers, you must explicitly configure the WASM file path.
1

Update next.config.ts

Add the required external packages:
2

Create a server-only configuration file

Create lib/shamela-server.ts:
3

Use in Server Actions

Import from your configuration file in server-side code:
Only import shamela in server-side code (Server Actions, API Routes, or Server Components). Never import in client components or layout.tsx.

Browser Environments

In browsers, the library automatically uses a CDN-hosted WASM file:

Your first API call

Once configured, you can start using the Shamela API.

Download a book

Download a complete book with all pages and titles:

Get master database

Retrieve the complete library catalog with all books, authors, and categories:

Download to file

Export books or master data to JSON or SQLite files:

Content processing

For client-side or lightweight use cases where you only need content utilities without database functionality, use the shamela/content export:
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.

Next steps

Explore the API reference to learn about all available functions:

Configuration

Learn about configuration options and environment variables

Metadata & Downloads

Download books and master databases

Content Utilities

Process and transform Arabic book content

Data Structures

Understand the data types returned by the API