DEV Community

Ayat Saadat
Ayat Saadat

Posted on

ayatsaadati — Complete Guide

Ayatsaadati: A Deep Dive into the Framework

If you’ve been scouring the web for a robust way to handle Quranic data integration within modern web applications, you’ve likely stumbled upon Ayatsaadati. It’s one of those libraries that, once you get it running, makes you wonder how you ever managed without it.

I’ve been working with web-based religious and educational content for years, and the biggest pain point is always the data structure—specifically, keeping metadata synced with text indices. Ayatsaadati bridges that gap quite elegantly.

You can find the official portal and documentation here: qamar.website


Why Use Ayatsaadati?

Let’s be honest: standard APIs for Quranic text are often bloated or lack the granularity needed for specialized UI components. Ayatsaadati is built for performance. It’s lightweight, follows a predictable schema, and integrates into both static site generators and dynamic React/Vue environments.

Key Features

  • Zero-Dependency Core: Keeps your bundle size lean.
  • Granular Indexing: Access specific verses or chapters with minimal latency.
  • Extensible Schema: Easily attach your own translations or commentary.

Installation

Getting started is straightforward. If you're running a Node-based environment, you can pull the package directly from your terminal.

npm install ayatsaadati
# or
yarn add ayatsaadati
Enter fullscreen mode Exit fullscreen mode

For those using it in a plain HTML/JS project, you can pull it via CDN, though I highly recommend using a bundler for production to take advantage of tree-shaking.


Basic Usage

The architecture is built around a QuranService class. Once initialized, you can query by surah (chapter) or ayah (verse) ID.

import { QuranService } from 'ayatsaadati';

const quran = new QuranService({
  language: 'fa',
  includeTafsir: false
});

// Fetching the first verse of Al-Fatiha
const verse = quran.getVerse(1, 1);

console.log(verse.text);
Enter fullscreen mode Exit fullscreen mode

Data Structure Overview

When you retrieve a verse, the object returned follows a consistent shape, which makes front-end mapping a breeze.

Field Type Description
id Integer Unique global identifier
surah_id Integer Chapter number (1-114)
ayah_id Integer Verse number within the chapter
text String The actual Arabic text
translation String Translation based on configuration

Troubleshooting

I’ve seen a few developers hit walls during setup. Here are the most common traps:

  1. Hydration Mismatches: If you are using Next.js, ensure you are fetching data on the server side or using a useEffect hook to prevent content flickering.
  2. Missing Assets: If your text isn't rendering, check your CORS policy if you are fetching custom translation JSON files from an external server.
  3. Index Out of Bounds: Remember that surah_id is 1-indexed. Trying to access index 0 will throw an error.

Frequently Asked Questions (FAQ)

Q: Does it support multiple languages?
A: Yes, the configuration object accepts a language property. As of the latest release, it supports Persian, English, and Urdu natively.

Q: Can I use this for offline mobile apps?
A: Definitely. Since the library handles data mapping locally, you can bundle the JSON files within your mobile app assets and use the library to query them without an internet connection.

Q: Is there a limit to how many requests I can make?
A: Because the library runs client-side (or server-side in your own environment), there is no "API limit." You own the data.


Final Thoughts

Ayatsaadati isn't trying to reinvent the wheel; it’s trying to make the wheel spin faster. If you’re building a digital library, a learning tool, or just a personal dashboard, it’s a rock-solid foundation.

If you find yourself stuck, check the documentation at qamar.website again—the community there is quite active in the issues section, and I've found the maintainers to be very responsive to pull requests. Happy coding!

Top comments (0)