Guide
Getting started
npm install @devix-labs/prayer-times
import { prayerTimes, formatTimes } from '@devix-labs/prayer-times';
const dubai = { latitude: 25.2048, longitude: 55.2708 };
const times = prayerTimes(dubai, new Date(), { country: 'AE' });
formatTimes(times, 'Asia/Dubai');
// { fajr: '04:46', sunrise: '06:01', dhuhr: '12:18', asr: '15:46', maghrib: '18:29', isha: '19:44' }
Each time is a Date, so you can format it however you like; formatTimes is the shortcut for the
common case of "in that city's own zone".
Pick a country
prayerTimes(coords, date, { country: 'AE' }); // UAE — General Authority of Islamic Affairs
prayerTimes(coords, date, { country: 'SA' }); // Umm al-Qura
prayerTimes(coords, date, { country: 'PK' }); // Karachi
A country brings its method and the minute adjustments that authority prints — the UAE, for instance, adds three minutes to Dhuhr, Asr and Maghrib and takes three off sunrise. That is why a timetable computed from raw angles never quite matches the mosque.
Unknown countries fall back to the Muslim World League.
Or pick a method
prayerTimes(coords, date, { method: 'umm-al-qura' });
| Key | Authority |
|---|---|
mwl |
Muslim World League |
egyptian |
Egyptian General Authority of Survey |
karachi |
University of Islamic Sciences, Karachi |
umm-al-qura |
Umm al-Qura University, Makkah |
dubai |
UAE — General Authority of Islamic Affairs |
qatar, kuwait, isna, singapore, turkey, tehran, jafari, france, russia |
as named |
Or pass a method of your own: { method: { key: 'mine', name: 'Mine', fajrAngle: 17.5, ishaAngle: 15 } }.
Asr
prayerTimes(coords, date, { country: 'PK', madhab: 'hanafi' }); // the later Asr
Your own adjustments
prayerTimes(coords, date, { country: 'AE', adjustments: { fajr: -2, isha: 3 } });
These stack on top of the method's own.
High latitudes
North of about 48° the sun sometimes never goes far enough below the horizon for Fajr or Isha, and inside the polar circles it may not rise or set at all.
prayerTimes(tromso, date, { highLatitudeRule: 'middle-of-the-night' }); // the default
prayerTimes(tromso, date, { highLatitudeRule: 'seventh-of-the-night' });
prayerTimes(tromso, date, { highLatitudeRule: 'twilight-angle' });
prayerTimes(tromso, date, { highLatitudeRule: 'none' }); // leaves them null
Where the sun does not rise or set at all, the day length of the nearest date that has one is used.
Any result that needed either of these carries estimated: true — show it, because a worshipper is
entitled to know the time was inferred.
The parts around the times
import { nextPrayer, currentPrayer, monthTimes, nightPortions } from '@devix-labs/prayer-times';
nextPrayer(dubai, { country: 'AE' });
// { name: 'asr', time: Date, inMinutes: 96 } ← for a countdown
currentPrayer(dubai, { country: 'AE' }); // 'dhuhr'
monthTimes(dubai, 2026, 9, { country: 'AE' }); // a printable timetable
nightPortions(dubai, new Date(), { country: 'AE' });
// { middle: Date, lastThird: Date } ← for Qiyam
Qibla
import { qibla, compassPoint, distanceToKaaba } from '@devix-labs/prayer-times';
qibla(51.5074, -0.1278); // 118.99
compassPoint(qibla(51.5074, -0.1278)); // 'ESE' — not the south-east people expect
distanceToKaaba(51.5074, -0.1278); // 4794 km
It is a great circle, which is why London points east-south-east.
How accurate is it?
Measured against adhan across 1 210 combinations of place, method, date and madhab — 7 260 individual times. 6 801 match to the minute; 459 differ by exactly one minute, which is rounding at the boundary; none differ by more. The comparison runs as a test on every build.
Rendering on the server
The calculation needs no browser API, so it runs anywhere JavaScript does — Node, a worker, an edge function. A PHP twin is planned; until it lands, render timetables from Node or call them at build time.