Menu

Build a Next.js Prayer Times Widget with a Live "Next Prayer" Countdown (App Router, No CORS Issues)
📰

Build a Next.js Prayer Times Widget with a Live "Next Prayer" Countdown (App Router, No CORS Issues)

DEV Community: javascript·SunnahSource·8 days ago
#3zaRJZ8R
#devtojavascript#devto#dev#ddd#eee
Long article (2493 words) — no AI summary yet.
Reading 0:00
15s threshold

Prayer times are the first feature almost every Muslim app needs. In this tutorial we build a small Next.js 15 (App Router) widget that:

fetches prayer times JSON on the server (so browser CORS rules never get in the way),

caches it with ISR ( revalidate: 3600 ),

shows Fajr, Dhuhr, Asr, Maghrib and Isha with their Arabic names,

highlights the next prayer and counts down to it, in the city's own time zone , not the visitor's or the server's,

keeps the time logic in plain functions you can unit test with node --test .

The data comes from the public sample of the SunnahSource Prayer Times API :

https : // sunnahsource . org / data / json / prayer - times . json

Enter fullscreen mode

Exit fullscreen mode

The sample is a fixed day for one city (Makkah, Umm Al-Qura method). The full API covers any city with several calculation methods. You request a key on the Prayer Times API page . The widget below works the same way with both, because it only reads timezone , times and items .

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.