ppg-js docs

ppg-js documentation

Measure heart rate, pulse-rate variability, and respiration from a fingertip on a phone camera in the browser.

ppg-js

ppg-js measures heart rate, pulse-rate variability, and respiration from a fingertip on a phone camera. It runs in the browser, has zero runtime dependencies, ships typed APIs with no UI, and includes a signal-quality gate that explains why it withholds a reading.

60-second overview

  1. Install the package or load its browser-global build.
  2. Create a PPG instance.
  3. Listen for state, metrics, quality, beat, waveform, respiration, and error events.
  4. Call start() from a user gesture so the browser can grant camera, wake-lock, and motion permissions.
  5. Put a fingertip over the rear camera and flash, then wait through SETTLING for MEASURING.
  6. Use readings only when metrics.quality.good is true.

Every session can be exported and replayed offline through the same signal engine. The hosted HRV Spot Check is a working example.

What it reports

FieldMeaning
heartRateBeats per minute, cross-checked between interval and spectral estimates
ibi, rmssd, sdnnLatest interval and variability over 60 seconds of accepted beats
rmssdFloorMsEstimated variability caused by the pipeline's own beat-timing noise
respirationRate, confidence, and basis from beat timing, amplitude, and baseline modulation
qualityA verdict with stable good, reason, and code fields

Start here