Installation
All PrayCalc packages are published to npm, written in TypeScript, and ship both ESM and CommonJS builds. Install only what you need.
Requirements
- Node.js 20 or later
- TypeScript 5.0 or later (optional but recommended)
- pnpm, npm, or yarn
pray-calc
The main prayer times engine. Supports all 14 standard calculation methods plus dynamic angle mode.
pnpm add pray-calc
Quick start
import { getPrayerTimes } from 'pray-calc'
const times = getPrayerTimes({
date: new Date(),
latitude: 41.4993,
longitude: -81.6944,
timezone: 'America/New_York',
method: 'ISNA',
})
console.log(times.fajr) // e.g. "05:34"
console.log(times.dhuhr) // e.g. "13:02"
console.log(times.asr) // e.g. "16:28"
console.log(times.maghrib) // e.g. "19:47"
console.log(times.isha) // e.g. "21:12"
nrel-spa
TypeScript port of the NREL Solar Position Algorithm. Used internally by pray-calc.
pnpm add nrel-spa
Quick start
import { computeSolarPosition } from 'nrel-spa'
const pos = computeSolarPosition({
date: new Date(),
latitude: 41.4993,
longitude: -81.6944,
elevation: 200, // metres above sea level
pressure: 1013.25, // millibars
temperature: 15, // °C
deltaT: 69.18, // seconds (ΔT for 2025)
})
console.log(pos.topocentricAltitude) // degrees above horizon
console.log(pos.topocentricAzimuth) // degrees clockwise from north
moon-sighting
JPL DE442S-based lunar crescent visibility. Requires downloading the kernel file separately (see package README).
pnpm add moon-sighting
Quick start
import { getMoonSightingReport } from 'moon-sighting'
const report = await getMoonSightingReport({
date: new Date('2025-03-01'),
latitude: 21.3891,
longitude: 39.8579, // Mecca
})
console.log(report.yallopCriteria) // 'A' | 'B' | 'C' | 'D' | 'F'
console.log(report.odehCriteria) // 'visible' | 'not-visible' | 'marginal'
moon-cycle
Maps any date/time to a NASA SVS moon phase image frame.
pnpm add moon-cycle
Quick start
import { cycleMonth, cdnUrl } from 'moon-cycle'
const frames = cycleMonth({ year: 2025, month: 3 })
const imageUrl = cdnUrl(frames[0])
console.log(imageUrl) // jsDelivr CDN URL for the frame image
hijri-core
Zero-dependency Hijri calendar engine.
pnpm add hijri-core
Quick start
import { toHijri, toGregorian } from 'hijri-core'
const hijri = toHijri(new Date('2025-03-29'))
console.log(hijri) // { year: 1446, month: 9, day: 29 }
const greg = toGregorian({ year: 1446, month: 10, day: 1 })
console.log(greg) // Date object: 2025-03-30
luxon-hijri
Hijri/Gregorian conversion with Luxon. Requires luxon as a peer dependency.
pnpm add luxon-hijri luxon
Quick start
import { toHijri, formatHijriDate } from 'luxon-hijri'
import { DateTime } from 'luxon'
const dt = DateTime.fromISO('2025-03-29')
const hijri = toHijri(dt)
console.log(hijri) // { year: 1446, month: 9, day: 29 }
const formatted = formatHijriDate(dt, 'iD iMMMM iYYYY')
console.log(formatted) // e.g. "29 Ramadan 1446"