The most comprehensive, lightweight, and offline-first Quran data package for JavaScript applications.
π Zero dependencies β’ π± Universal compatibility β’ π Offline-first β’ π Complete Quran β’ π Full-text search β’ π Tanzil authentic β’ π§© TypeScript ready β’ π― Tree-shakable
| Feature | Description |
|---|---|
| π Zero Dependencies | No external dependencies, self-contained package |
| π± Universal Platform | Works seamlessly in Node.js, browsers, React, Vue, React Native, and more |
| π Offline-First | Complete Quran text included, no network requests required |
| π Complete Dataset | All 114 surahs with 6,236 ayat, 30 Juz, 60 Hizb divisions |
| π Powerful Search | Built-in Arabic text search and intelligent surah discovery |
| π Authentic Source | Based on official Tanzil Project Uthmani minimal text |
| π§© TypeScript Ready | Complete TypeScript definitions with detailed JSDoc documentation |
| π― Tree-Shakable | ES modules support for optimal bundle sizes in modern applications |
| π Rich Analytics | Comprehensive statistics and insights for educational applications |
| β‘ Performance | Optimized data structure with efficient lookup algorithms |
npm install @muslims-community/quranimport { getAyah, getSurah, searchText } from '@muslims-community/quran';
// Get Ayat al-Kursi
const ayatAlKursi = getAyah(2, 255);
console.log(ayatAlKursi.text);
// Get complete Al-Fatiha
const alFatiha = getSurah(1);
console.log(`${alFatiha.englishName}: ${alFatiha.numberOfAyahs} ayat`);
// Search for "Allah"
const results = searchText('Ψ§ΩΩΩ');
console.log(`Found ${results.totalResults} ayat containing "Ψ§ΩΩΩ"`);import { getJuz, getAyahRange, getSurahStatistics, searchBySurahName } from '@muslims-community/quran';
// Daily Juz reading
const juz1 = getJuz(1);
console.log(`Juz 1: ${juz1.totalAyat} ayat`);
// Range reading for study
const range = getAyahRange(18, 1, 10); // Al-Kahf 1-10
console.log(`Reading ${range.range.count} ayat from ${range.surah.englishName}`);
// Find surahs easily
const kahf = searchBySurahName('Cave'); // Finds Al-Kahf
console.log(`Found: ${kahf.results[0].englishName}`);
// Get comprehensive statistics
const stats = getSurahStatistics();
console.log(`π ${stats.totalSurahs} surahs, ${stats.totalAyat} ayat`);- π API Overview - Complete function reference with examples
- π Quick Start Guide - Get up and running in minutes
- π TypeScript Guide - Full type safety and IntelliSense
- π Basic Functions -
getAyah(),getSurah(),getQuranData() - π Search Functions -
searchText(),searchBySurahName() - π² Random & Special -
getRandomAyah(),getSajdahAyat()
- π Range Reading -
getAyahRange()for reading applications - π Juz & Hizb Guide -
getJuz(),getHizb()for daily reading plans - π Statistics Guide -
getSurahStatistics()for analytics and insights
- βοΈ React Integration - Building React apps with hooks and components
- π’ Node.js Guide - Server-side usage patterns and APIs
- π¨ UI Components - Ready-to-use interface components
- π§ Performance Tips - Optimization strategies for large apps
- ποΈ Data Structure - Understanding Quran data format and organization
- π Islamic Concepts - Juz, Hizb, Sajdah, and revelation context
- π Internationalization - Multi-language support and text direction
| Function | Purpose | Returns | Version |
|---|---|---|---|
getAyah(surahId, ayahId) |
Get specific ayah with metadata | AyahWithSurah |
1.0.0 |
getSurah(surahId) |
Get complete surah with all ayat | Surah |
1.0.0 |
getQuranData() |
Get complete Quran dataset | QuranData |
1.0.0 |
searchText(searchTerm) |
Search Arabic text across Quran | SearchResult |
1.0.0 |
getRandomAyah() |
Get random ayah for inspiration | AyahWithSurah |
1.0.0 |
getSajdahAyat() |
Get all prostration verses | SajdahResult |
1.0.0 |
| Function | Purpose | Returns | Use Case |
|---|---|---|---|
getAyahRange(surahId, start, end) |
Get consecutive ayat range | AyahRange |
Reading apps, study sessions |
getJuz(juzNumber) |
Get complete Juz (1-30) | JuzResult |
Daily reading, progress tracking |
getHizb(hizbNumber) |
Get complete Hizb (1-60) | HizbResult |
Flexible reading portions |
searchBySurahName(name) |
Find surahs by name | SurahSearchResult |
Surah discovery, navigation |
getSurahStatistics() |
Get comprehensive stats | SurahStatistics |
Analytics, educational insights |
import { getJuz, getSurahStatistics } from '@muslims-community/quran';
class QuranReadingPlan {
constructor() {
this.stats = getSurahStatistics();
}
// Get today's reading based on date
getTodayReading() {
const day = new Date().getDate();
const juzNumber = ((day - 1) % 30) + 1;
const juz = getJuz(juzNumber);
return {
day: day,
juz: juzNumber,
totalAyat: juz.totalAyat,
estimatedMinutes: Math.round(juz.totalAyat / 2),
progress: Math.round((juzNumber / 30) * 100),
ayat: juz.ayat
};
}
// Generate 30-day reading schedule
getCompleteSchedule() {
return Array.from({ length: 30 }, (_, i) => {
const juz = getJuz(i + 1);
return {
day: i + 1,
juz: i + 1,
ayatCount: juz.totalAyat,
estimatedTime: `${Math.round(juz.totalAyat / 2)} mins`
};
});
}
}
const readingPlan = new QuranReadingPlan();
const todayReading = readingPlan.getTodayReading();
console.log(`π
Day ${todayReading.day}: Read Juz ${todayReading.juz} (${todayReading.estimatedMinutes} mins)`);import { searchText, searchBySurahName, getAyahRange } from '@muslims-community/quran';
class QuranSearch {
// Intelligent search with context
async smartSearch(query) {
// Try surah name first
const surahResults = searchBySurahName(query);
if (surahResults.totalResults > 0) {
return {
type: 'surah',
query,
results: surahResults.results,
suggestion: `Found ${surahResults.totalResults} surah(s) matching "${query}"`
};
}
// Then try text search
const textResults = searchText(query);
if (textResults.totalResults > 0) {
// Add context to results
const enhancedResults = textResults.results.slice(0, 20).map(ayah => ({
...ayah,
context: this.getContext(ayah.surah.id, ayah.id)
}));
return {
type: 'text',
query,
results: enhancedResults,
totalResults: textResults.totalResults,
suggestion: `Found ${textResults.totalResults} ayat containing "${query}"`
};
}
return {
type: 'none',
query,
results: [],
suggestion: `No results found for "${query}". Try "Ψ§ΩΩΩ", "Ψ±Ψ¨", or surah names like "Fatiha"`
};
}
// Get context around found ayah
getContext(surahId, ayahId, contextSize = 1) {
try {
const start = Math.max(1, ayahId - contextSize);
const end = ayahId + contextSize;
return getAyahRange(surahId, start, end);
} catch (error) {
return null;
}
}
}
const search = new QuranSearch();
const results = await search.smartSearch('Cave');
console.log(results.suggestion);import { getSurahStatistics, getJuz } from '@muslims-community/quran';
class QuranAnalytics {
constructor() {
this.stats = getSurahStatistics();
}
generateInsights() {
// Reading time calculations
const avgReadingSpeed = 2; // ayat per minute
const totalMinutes = Math.round(this.stats.totalAyat / avgReadingSpeed);
// Juz analysis
const juzSizes = Array.from({ length: 30 }, (_, i) => {
const juz = getJuz(i + 1);
return juz.totalAyat;
});
const avgJuzSize = Math.round(juzSizes.reduce((a, b) => a + b, 0) / 30);
return {
overview: {
totalSurahs: this.stats.totalSurahs,
totalAyat: this.stats.totalAyat.toLocaleString(),
readingTime: `${Math.round(totalMinutes / 60)} hours`,
dailyReadingPlan: `${Math.round(totalMinutes / 30)} minutes/day for 30 days`
},
revelation: {
meccan: `${this.stats.meccanSurahs} surahs (${Math.round(this.stats.meccanSurahs/114*100)}%)`,
medinan: `${this.stats.medinanSurahs} surahs (${Math.round(this.stats.medinanSurahs/114*100)}%)`,
meccanAvgLength: Math.round(this.stats.revelationAnalysis.meccanCharacteristics.averageLength),
medinanAvgLength: Math.round(this.stats.revelationAnalysis.medinanCharacteristics.averageLength)
},
structure: {
longest: `${this.stats.longestSurah.englishName} (${this.stats.longestSurah.numberOfAyahs} ayat)`,
shortest: `${this.stats.shortestSurah.englishName} (${this.stats.shortestSurah.numberOfAyahs} ayat)`,
averageLength: `${this.stats.averageAyatPerSurah} ayat per surah`,
juzSystem: `30 Juz averaging ${avgJuzSize} ayat each`
},
interestingFacts: [
`The longest surah is ${Math.round(this.stats.longestSurah.numberOfAyahs / this.stats.shortestSurah.numberOfAyahs)}x longer than the shortest`,
`Meccan surahs average ${Math.round(this.stats.revelationAnalysis.meccanCharacteristics.averageLength)} ayat vs ${Math.round(this.stats.revelationAnalysis.medinanCharacteristics.averageLength)} for Medinan`,
`Reading 1 Juz daily completes the Quran in exactly 30 days`,
`The most common surah length is ${this.stats.ayatCounts.mode} ayat`
]
};
}
}
const analytics = new QuranAnalytics();
const insights = analytics.generateInsights();
console.log('π Quran Insights:', insights);import { useState, useEffect } from 'react';
import { getJuz, getRandomAyah } from '@muslims-community/quran';
function useDailyQuran() {
const [dailyReading, setDailyReading] = useState(null);
const [inspirationalAyah, setInspirationalAyah] = useState(null);
useEffect(() => {
const dayOfYear = Math.floor((Date.now() - new Date(new Date().getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));
const juzNumber = ((dayOfYear - 1) % 30) + 1;
setDailyReading(getJuz(juzNumber));
setInspirationalAyah(getRandomAyah());
}, []);
return { dailyReading, inspirationalAyah };
}
// Usage in component
function DailyQuranComponent() {
const { dailyReading, inspirationalAyah } = useDailyQuran();
if (!dailyReading || !inspirationalAyah) {
return <div className="loading">Loading today's reading...</div>;
}
return (
<div className="daily-quran">
<section className="daily-reading">
<h2>π Today's Reading - Juz {dailyReading.juz}</h2>
<p>{dailyReading.totalAyat} ayat β’ ~{Math.round(dailyReading.totalAyat / 2)} minutes</p>
<div className="ayat-preview">
{dailyReading.ayat.slice(0, 3).map(ayah => (
<div key={`${ayah.surah.id}-${ayah.id}`} className="ayah">
<p className="arabic">{ayah.text}</p>
<small>{ayah.surah.englishName} {ayah.id}</small>
</div>
))}
</div>
</section>
<section className="inspiration">
<h3>π‘ Inspiration</h3>
<blockquote className="arabic">{inspirationalAyah.text}</blockquote>
<cite>{inspirationalAyah.surah.englishName} {inspirationalAyah.id}</cite>
</section>
</div>
);
}<template>
<div class="quran-search">
<input
v-model="searchQuery"
@input="handleSearch"
placeholder="Search Quran..."
class="search-input"
/>
<div v-if="loading" class="loading">Searching...</div>
<div v-else-if="results.length" class="results">
<div
v-for="result in results"
:key="`${result.surah.id}-${result.id}`"
class="result-item"
>
<p class="arabic">{{ result.text }}</p>
<small>{{ result.surah.englishName }} {{ result.id }}</small>
</div>
</div>
</div>
</template>
<script setup>
import { ref, watch } from 'vue';
import { searchText, searchBySurahName } from '@muslims-community/quran';
const searchQuery = ref('');
const results = ref([]);
const loading = ref(false);
const handleSearch = async () => {
if (!searchQuery.value.trim()) {
results.value = [];
return;
}
loading.value = true;
try {
// Try surah search first
const surahResults = searchBySurahName(searchQuery.value);
if (surahResults.totalResults > 0) {
results.value = surahResults.results[0].ayat.slice(0, 10);
} else {
// Fall back to text search
const textResults = searchText(searchQuery.value);
results.value = textResults.results.slice(0, 20);
}
} catch (error) {
console.error('Search error:', error);
results.value = [];
} finally {
loading.value = false;
}
};
</script>const express = require('express');
const cors = require('cors');
const {
getAyah,
getSurah,
searchText,
getJuz,
getSurahStatistics,
searchBySurahName
} = require('@muslims-community/quran');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
// Ayah endpoints
app.get('/api/ayah/:surahId/:ayahId', (req, res) => {
try {
const { surahId, ayahId } = req.params;
const ayah = getAyah(parseInt(surahId), parseInt(ayahId));
res.json({ success: true, data: ayah });
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
});
// Surah endpoints
app.get('/api/surah/:id', (req, res) => {
try {
const surah = getSurah(parseInt(req.params.id));
res.json({ success: true, data: surah });
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
});
// Search endpoints
app.get('/api/search/text/:term', (req, res) => {
try {
const results = searchText(decodeURIComponent(req.params.term));
res.json({
success: true,
data: {
...results,
results: results.results.slice(0, 50) // Limit for API response
}
});
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
});
app.get('/api/search/surah/:name', (req, res) => {
try {
const results = searchBySurahName(decodeURIComponent(req.params.name));
res.json({ success: true, data: results });
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
});
// Juz endpoints
app.get('/api/juz/:number', (req, res) => {
try {
const juz = getJuz(parseInt(req.params.number));
res.json({ success: true, data: juz });
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
});
// Statistics endpoint
app.get('/api/statistics', (req, res) => {
try {
const stats = getSurahStatistics();
res.json({ success: true, data: stats });
} catch (error) {
res.status(500).json({ success: false, error: error.message });
}
});
// Health check
app.get('/api/health', (req, res) => {
res.json({
success: true,
message: 'Quran API is running',
version: '1.1.0',
endpoints: [
'GET /api/ayah/:surahId/:ayahId',
'GET /api/surah/:id',
'GET /api/search/text/:term',
'GET /api/search/surah/:name',
'GET /api/juz/:number',
'GET /api/statistics'
]
});
});
app.listen(PORT, () => {
console.log(`π Quran API server running on port ${PORT}`);
console.log(`π Documentation: http://localhost:${PORT}/api/health`);
});
module.exports = app;| Platform | Support | Installation | Import Method |
|---|---|---|---|
| Node.js | β Full | npm install |
require() or import |
| Browsers | β Full | CDN or bundler | import from ES modules |
| React | β Full | npm install |
import with hooks/components |
| React Native | β Full | npm install |
import (Metro bundler) |
| Vue.js | β Full | npm install |
import with Composition API |
| Angular | β Full | npm install |
import in services |
| Next.js | β Full | npm install |
SSR/SSG compatible |
| Nuxt.js | β Full | npm install |
Universal mode support |
| Electron | β Full | npm install |
Both main/renderer processes |
| Svelte | β Full | npm install |
import in components |
| Metric | Value | Description |
|---|---|---|
| Bundle Size | ~310 KB | Optimized with tree-shaking |
| Unpacked Size | ~2.0 MB | Complete Quran data included |
| Dependencies | 0 | Zero external dependencies |
| TypeScript | 100% | Complete type definitions |
| Functions | 11 total | 6 core + 5 enhanced (v1.1.0) |
| Test Coverage | 95%+ | Comprehensive test suite |
| Performance | β‘ Fast | Optimized lookup algorithms |
| Memory Usage | Low | Efficient data structures |
- β
5 New Functions:
getAyahRange(),getJuz(),getHizb(),searchBySurahName(),getSurahStatistics() - β Enhanced Data: Juz/Hizb mapping, revelation chronology
- β TypeScript: Complete definitions for all functions
- β Documentation: Comprehensive wiki guides
- β Testing: 86% increased test coverage
- β Backward Compatible: All v1.0.x code continues to work
- π§ Fixed repository URLs and documentation links
- β 6 Core Functions: Complete Quran access and search
- β Complete Dataset: All 114 surahs, 6,236 ayat
- β Universal Compatibility: Node.js, browsers, frameworks
- β TypeScript Support: Full type definitions
- β Authentic Source: Tanzil Project Uthmani text
We welcome contributions from the Muslim developer community and beyond!
- π Report Bugs - Help us improve quality
- π‘ Request Features - Suggest new functionality
- π Improve Documentation - Help others learn
- π§ͺ Add Tests - Increase reliability
- π Translate Docs - Make it accessible globally
git clone https://github.com/Muslims-Community/quran-data-js.git
cd quran-data-js
npm install
npm test- π Homepage
- π Documentation
- π Issues
- π¬ Discussions
- π§ Contact (coming soon)
- MIT License - Free for commercial and non-commercial use
- No restrictions on distribution, modification, or private use
- Source: Tanzil Project - Uthmani Minimal v1.1
- License: Creative Commons Attribution 3.0
- Requirements: Attribution to Tanzil Project must be maintained
- Restrictions: Quran text cannot be modified
- π§ Navigation Functions:
getNextAyah(),getPreviousAyah(),getNextSurah() - π Advanced Search: Fuzzy search, filters, relevance scoring
- π Reading Plans: Automated plan generators for different schedules
- π± Mobile Optimizations: React Native specific enhancements
- π·οΈ Thematic Organization: Group ayat by themes and topics
- π Word Analytics: Frequency analysis and word-level insights
- π€ Export Functions: JSON, CSV, and other format exports
- π Cross-References: Link related ayat and concepts
- π Translation Integration: Multiple language support
- π΅ Audio Data: Recitation integration capabilities
- π€ AI Features: Smart recommendations and insights
- βοΈ Cloud Sync: Optional online features and synchronization
This package is created and maintained by developers who love both code and the Quran. Our mission is to make Quranic knowledge easily accessible through modern technology while maintaining the highest standards of authenticity and respect.
- β Authenticity: Using verified Tanzil Project text
- β Accessibility: Making Quran available to all developers
- β Quality: Following best practices in software development
- β Community: Encouraging collaboration and knowledge sharing
- β Respect: Maintaining the sanctity and accuracy of Quranic text
"And We have certainly made the Qur'an easy for remembrance, so is there any who will remember?" - Al-Qamar 54:17