Skip to main content

NHPR SDK - Implementation

This guide provides everything you need to integrate the NHPR SDK (M4) into your application.

Overview

The NHPR SDK (M4) is a plug-and-play UI widget that enables your application to onboard doctors onto ABDM’s Health Professional Registry (HPR) and register their clinic as a Healthcare Facility Registry (HFR) entry — all from within your existing web application. It provides:
  • Aadhaar-based identity verification: Doctor’s identity is verified using ABDM’s Aadhaar OTP flow.
  • HPR ID creation: Doctor selects a unique HPR ID, practice type, email, and password.
  • HFR facility registration: Clinic is registered or linked as an ABDM healthcare facility.
  • Onboarding callbacks: Your application receives the resulting HPR ID and HFR Facility ID on success.

Installation

Prerequisites

  • A modern web browser.
  • Your domain must be whitelisted with Eka Care to avoid CORS errors. (Contact Eka Care to request API access and domain whitelisting.)
  • A valid HTML container element where the SDK will mount.
  • A short-lived Bearer access token generated from your backend using the Connect Login API.

Setup

Add the following to your webpage:
For staging/dev environments, replace the SDK URLs with:
  • JS: https://unpkg.com/@eka-care/abdm-dashboard-stg/dist/sdk/abdm/js/abdm.js
  • CSS: https://unpkg.com/@eka-care/abdm-dashboard-stg/dist/sdk/abdm/css/abdm.css

Core Functions

1. mountABDMDashboard

Initializes and renders the NHPR SDK in your specified container. Parameters:

2. unmountABDMDashboard

Programmatically unmounts the widget and cleans up the React root.
Returns true if the widget was found and unmounted, false if no mounted widget was found at the given element ID.

Callback Parameters

onAbdmMountSuccess Callback

Fired immediately after the widget mounts and renders successfully into the container. Callback Signature:
Type Definition:
Parameters: Example:

onAbdmOnboardSuccess Callback

Fired when the full HPR + HFR onboarding flow completes successfully. This is the primary callback — use it to persist the HPR ID and HFR Facility ID to your backend. Callback Signature:
Type Definition:
Parameters: Example:

onAbdmDashboardClose Callback

Fired when the user explicitly closes the widget (by clicking the back/close button) or when unmountABDMDashboard is called programmatically. Callback Signature:
Type Definition:
Parameters: Example:

onAbdmDashboardError Callback

Fired if the widget fails to mount or encounters a fatal error during initialisation. Callback Signature:
Type Definition:
Parameters: Example:
Suggested handling:
  • Always log the full params for debugging.
  • Display a user-friendly retry prompt — the most common causes are an expired accessToken or a network failure.
  • Generate a fresh accessToken from your backend before retrying mountABDMDashboard.

Onboarding Flow (M4)

The widget is a linear multi-step flow. Each step is a full-screen state — the user cannot jump ahead.

Screen reference

Practice types

HPR password requirements

The widget validates the password live as the doctor types. All rules must pass before the form can be submitted:
  • At least 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • At least one special character

OTP Auto-Read (Mobile WebView)

If your application embeds the widget in a mobile WebView that supports OTP interception, forward the OTP to the widget:
The widget pre-fills the OTP input automatically and does not require the doctor to type it.

Container Styling

Ensure your container has sufficient height for the widget to render correctly:
For full-screen modal use cases, set the container to 100vw / 100vh and pass hideEkaSidePanel: true to disable the side illustration panel on smaller viewports.

API Reference

The widget communicates with Eka’s backend. All requests include your accessToken as a Bearer token in the Authorization header. Base URLs:

Troubleshooting

Common Issues

1. SDK Not Rendering

Problem: Nothing appears in the container. Solution:
  • Ensure elementId matches an existing HTML element ID.
  • Verify the SDK JS and CSS files are loaded before calling mountABDMDashboard.
  • Check the browser console for errors.

2. APIs Not Being Called

Problem: API requests are not triggered after the SDK is mounted. Solution:
  • Ensure accessToken is passed correctly and has not expired — generate a fresh token from your backend on each mount.
  • Ensure your domain is whitelisted with Eka Care to prevent CORS errors.

3. Callbacks Not Firing

Problem: onAbdmOnboardSuccess, onAbdmDashboardClose, or onAbdmDashboardError are not being called. Solution:
  • Confirm callbacks are passed as valid functions, not strings or undefined.
  • Avoid calling unmountABDMDashboard before the SDK has finished its flow — this will silently stop all further callbacks.

4. Styling Issues

Problem: SDK content appears misaligned or clipped. Solution:
  • Give your container a fixed height (e.g., 600px) or 100vh for full-screen.
  • Ensure no parent element applies overflow: hidden that would clip the widget.
  • Pass hideEkaSidePanel: true on narrow viewports (under 768 px).

Frequently Asked Questions

An HPR (Health Professional Registry) ID is a unique digital identity for healthcare professionals in India’s ABDM ecosystem. It is required for a doctor to participate in ABDM-enabled workflows such as linking patient health records and issuing digital prescriptions.
HFR (Healthcare Facility Registry) registers a clinic or hospital within ABDM. It is required for the clinic to act as a Health Information Provider (HIP) and exchange records through the ABDM network. The NHPR SDK handles both HPR and HFR registration in a single flow.
Store both in your backend against the respective doctor and clinic records. The facilityId is the HFR ID assigned by ABDM to the clinic. The createdHprId is the doctor’s new HPR ID in the format username@hpr.abdm. You will need these IDs for subsequent ABDM API calls.
Pass hideEkaSidePanel: true to collapse the side illustration panel for narrow screens. Wire up your native OTP-intercept handler to call window.onOtpAutoRead({ success: true, otp: '...' }) so the OTP field is filled automatically.
The current M4 flow creates a new HPR ID via Aadhaar-based identity verification. If the doctor already has an HPR ID registered with ABDM, contact Eka support to enable the existing-HPR linking flow for your integration.