Skip to content

Self-hosting and offline

By default the script and everything it loads come from unpkg. You can serve them yourself, from your own server or from inside an app, so pages render without unpkg or without any internet connection.

What to serve

From the npm package (npm install quran-madina-html), keep this folder structure:

Path What
dist/quran-madina-html.js the script
dist/quran-madina-html.css its styles (loaded by the script)
assets/img/ the sura frame
assets/db/v2/<stem>/ the text and layout of one print, split per juz'
assets/db/v2/<font>-qmh.woff2 that print's font

Through version 2.x, dist/ also holds the same two files under their old names, quran-madina-html.min.js and .min.css, so pages that link those keep working. Use the names above; the old ones go in 3.0.

The stems and fonts by layout:

Layout Database folder Font
1441H Madina-1441H/ madina-qmh.woff2
1405H Madina-1405H/ oldmadina-qmh.woff2
IndoPak IndoPak-15/ indopak-qmh.woff2

Each print takes about 4 MB. Serve only the ones you use.

Point the script at your copy

data-cdn is the base URL that holds dist/ and assets/:

<script src="/static/qmh/dist/quran-madina-html.js" data-cdn="/static/qmh/"></script>
{/* src, cdn and bundled apply to the whole page: set them on the first component */}
<QuranMadinaHtml page={1} src="/static/qmh/dist/quran-madina-html.js" cdn="/static/qmh/" />
{/* or offline, from the app's own copy (npx quran-madina-bundle; see React: Offline) */}
<QuranMadinaHtml page={1} bundled />
{/* from your own server */}
<QuranMadinaNative page={1} src="https://example.com/qmh/dist/quran-madina-html.js" cdn="https://example.com/qmh/" />
{/* or offline, from the app's own copy (npx quran-madina-native-bundle; see React Native: Offline) */}
<QuranMadinaNative page={1} bundled />
// from your own server
QuranMadinaFlutter(
  page: 1,
  src: 'https://example.com/qmh/dist/quran-madina-html.js',
  cdn: 'https://example.com/qmh/',
)
// or offline, from the app's own assets (see Flutter: online or offline)
QuranMadinaFlutter(page: 1, bundled: true)

Everything, the font included, then loads from there.

The localhost rule

Without data-cdn, the script loads its files from unpkg, except on a page served from localhost, where it assumes the files are one folder up (../). That is how this repository's own demo works locally. A dev server or an app shell that also runs on localhost (a React dev server, Capacitor) does not have the files there, so set data-cdn in those cases. The React and Flutter wrappers do it for you.

Apps

  • React (web, or iOS and Android with Capacitor): one command copies the files into public/. See React.
  • React Native: one command copies the files into the Android and iOS projects. See React Native.
  • Flutter: one command copies the files into the app's assets. See Flutter.