npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

open-quran-view

v0.5.0

Published

Universal, cross-platform Quran component library for high-fidelity Mushaf rendering.

Readme

open-quran-view

NPM Package · Docs · Live Demo · Production Example

High-performance universal Quran rendering library using Quran Foundation API.

open-quran-view provides React and Web Component views for rendering Quran pages with high fidelity.


Features

  • Quran Foundation API - Uses Quran Foundation API for platform-agnostic data.
  • Universal Views - React component and Vanilla Web Component with consistent API.
  • TypeScript First - Built with TypeScript for a robust development experience.
  • Static Assets - Self-contained fonts and metadata included in package.
  • Word-Level Interactivity - Click on words for tafseer and explanations.
  • Multiple Mushaf Layouts - Support for Hafs V2, Hafs V4, and Hafs Unicode.

Project Structure

open-quran-view/
├── src/
│   ├── core/               # Platform-agnostic core logic
│   │   ├── static/         # Static asset URLs
│   │   ├── data-loader.ts  # Data loading with caching
│   │   ├── font-loader.ts  # Font loading
│   │   └── lookup.ts       # Navigation & verse lookup
│   ├── view/
│   │   ├── react/          # React component
│   │   └── web/            # Web Component
│   ├── data/               # Quran Foundation API data assets (generated)
├── docs/                   # Documentation
├── scripts/                # Data generation scripts
├── playground/             # React & Web Component development playgrounds
└── dist/                   # Build output

Getting Started

Installation

npm install open-quran-view

React Component

import { OpenQuranView } from 'open-quran-view/view';

function App() {
  return (
    <OpenQuranView
      page={1}
      mushafLayout="hafs-v2"
      width={600}
      height={850}
      onWordClick={(word) => console.log(word)}
    />
  );
}

Explicit imports:

import { OpenQuranView } from 'open-quran-view/view/react';

Web Component

<script type="module">
  import { registerOpenQuranView } from 'open-quran-view/view/web';
  registerOpenQuranView();
</script>

<open-quran-view page="1" mushaf-layout="hafs-v2" width="600" height="850"></open-quran-view>

TypeScript:

import { registerOpenQuranView, type OpenQuranViewElement } from 'open-quran-view/view/web';
registerOpenQuranView();

const viewer = document.querySelector('open-quran-view') as OpenQuranViewElement;
viewer.page = 1;
viewer.setAttribute('mushaf-layout', 'hafs-v2');

API Reference

React Component (@open-quran-view/view)

import { OpenQuranView, type OpenQuranViewProps } from 'open-quran-view/view';

<OpenQuranView
  page={1}
  width={600}
  height={850}
  theme="light"
  mushafLayout="hafs-v2"
  onPageChange={(page) => console.log(page)}
  onLoad={(layout) => console.log(layout)}
  onWordClick={(word) => console.log(word)}
/>

Props:

| Prop | Type | Default | Description | |------|------|---------|-------------| | page | number | 1 | Page number (1-604) | | width | number | 600 | Component width in pixels | | height | number | 850 | Component height in pixels | | theme | "light" \| "dark" | "light" | Color theme | | mushafLayout | "hafs-v2" \| "hafs-v4" \| "hafs-unicode" | "hafs-v2" | Mushaf layout | | onPageChange | (page: number) => void | - | Called when page changes | | onLoad | (layout: PageLayout) => void | - | Called when page loads | | onWordClick | (word: WordInfo) => void | - | Called when word is clicked | | highlightedWords | WordLocation[] | [] | List of words to highlight | | highlightedVerse | { surah: number, verse: number } \| null | null | Verse to highlight (line background) | | wordHighlightColor | string | "rgba(255, 215, 0, 0.5)" | Word highlight color | | verseHighlightColor | string | "rgba(135, 206, 250, 0.25)" | Verse highlight color | | className | string | - | CSS class for container |

type WordInfo = { id: number; surahNumber?: number; ayahNumber?: number; };

type WordLocation = { surah: number; verse: number; position: number; };


### Web Component (`@open-quran-view/view/web`)

```typescript
import { registerOpenQuranView, type OpenQuranViewProps } from 'open-quran-view/view/web';
registerOpenQuranView();

Attributes:

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | page | string | "1" | Page number (1-604) | | mushaf-layout | string | "hafs-v2" | Mushaf layout | | width | string | "600" | Component width in pixels | | height | string | "850" | Component height in pixels | | theme | string | "light" | Color theme (light or dark) | | highlighted-words | string | undefined | JSON string of WordLocation[] | | highlighted-verse | string | undefined | JSON string of { surah: number, verse: number } | | word-highlight-color | string | "rgba(255, 215, 0, 0.5)" | Word highlight color | | verse-highlight-color | string | "rgba(135, 206, 250, 0.25)" | Verse highlight color |

Events:

| Event | Detail | Description | |-------|--------|-------------| | load | PageLayout | Fired when page loads | | pagechange | { page: number } | Fired when page changes | | wordclick | WordInfo | Fired when a word is clicked |

JavaScript API:

const viewer = document.querySelector('open-quran-view') as OpenQuranView;

viewer.page = 10;
viewer.goToPage(10);
console.log(viewer.page);
viewer.setAttribute('mushaf-layout', 'hafs-v4');
viewer.setAttribute('theme', 'dark');

// Highlighting API
viewer.wordsHighlight = [{ surah: 1, verse: 1, position: 1 }];
viewer.verseHighlight = { surah: 1, verse: 1 };
viewer.wordHighlightColorOverride = 'rgba(255, 0, 0, 0.3)';

Mushaf Layouts

| Layout | Description | Preview | |--------|-------------|---------| | hafs-v2 | Hafs from Asim via the way of Warsh | Hafs v2 | | hafs-v4 | Hafs from Asim via the way of Shu'bah (with Tajweed) | Hafs v4 with Tajweed | | hafs-unicode | Standard Unicode Quran (Digital Khatt) | Unicode Digital Khatt |


Bismillah Rendering

Bismillah is rendered correctly across all layouts following Quranic rules:

| Surah | Behavior | |-------|----------| | Surah 1 (Al-Fatiha) | Bismillah shown as Ayah 1 | ✅ | | Surah 9 (At-Tawbah) | No Bismillah shown | ✅ | | All other Surahs | Decorative centered Bismillah line after Surah header | ✅ |

Each layout uses its own dedicated font for Bismillah rendering:

  • hafs-unicode → DigitalKhatt font
  • hafs-v2 → Hafs v2 font (BismillahFont)
  • hafs-v4 → Hafs v4 font (BismillahFont)

Documentation

See docs/ directory for:


Scripts

| Script | Description | |--------|-------------| | yarn generate:all | Download fonts + fetch data + generate all static assets | | yarn generate:static:fonts | Download fonts from Quran Foundation API and generate font URLs | | yarn generate:static:data | Fetch Quran data from Quran Foundation API and generate page layouts | | yarn build | Build the package | | yarn prepare | Auto-generate + build on install | | yarn test | Run tests | | yarn lint | Lint code |


Development

# Install dependencies
yarn install

# Generate static assets
yarn generate:all

# Build package
yarn build

# Run development playground
yarn playground:setup
yarn playground:react
yarn playground:web

Jazakum Allahu Khairan