# fhirclient

> JavaScript client for Fast Healthcare Interoperability Resources

Latest version **2.6.3** (published 2025-09-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install fhirclient
pnpm add fhirclient
yarn add fhirclient
bun add fhirclient
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.6.3 |
| Published | 2025-09-26 |
| First published | 2015-06-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 354 |
| Author | SMART Health IT |
| Maintainers | dtphelan1, smarthealthit-chip |
| Keywords | SMART, FHIR, Client |

## Links

- npm: https://www.npmjs.com/package/fhirclient
- Repository: https://github.com/smart-on-fhir/client-js
- Homepage: http://docs.smarthealthit.org/client-js/
- Issues: https://github.com/smart-on-fhir/client-js/issues
- npm.io page: https://npm.io/package/fhirclient

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.6.3 (latest) — 2025-09-26
- 3.0.0-beta.2 (beta) — 2025-09-29
- 2.3.9 (dev) — 2020-10-09
- 3.0.0-beta.1 — 2025-09-25
- 2.6.2 — 2025-09-19
- 2.6.1 — 2025-09-19
- 2.6.0 — 2025-05-28
- 2.5.5 — 2025-02-17
- 2.5.4 — 2024-08-27
- 2.5.3 — 2024-02-07
- 2.5.2 — 2022-09-01
- 2.5.1 — 2022-08-18
- 2.5.0 — 2022-08-11
- 2.4.0 — 2021-06-10
- 2.3.11 — 2021-02-10
- … 35 more at https://npm.io/package/fhirclient/versions

## README

SMART on FHIR JavaScript Library
================================

This is a JavaScript library for connecting SMART apps to FHIR servers.
It works both in browsers (IE 10+) and on the server (Node 10+).


[![NodeJS Tests](https://github.com/smart-on-fhir/client-js/actions/workflows/node.yml/badge.svg?branch=master)](https://github.com/smart-on-fhir/client-js/actions/workflows/node.yml)
[![Browser Tests](https://github.com/smart-on-fhir/client-js/actions/workflows/browser.yml/badge.svg?branch=master)](https://github.com/smart-on-fhir/client-js/actions/workflows/browser.yml)
[![Coverage Status](https://coveralls.io/repos/github/smart-on-fhir/client-js/badge.svg?branch=master)](https://coveralls.io/github/smart-on-fhir/client-js?branch=master)
[![npm version](https://badge.fury.io/js/fhirclient.svg)](https://badge.fury.io/js/fhirclient)
[![types](https://badgen.net/npm/types/fhirclient)](https://badgen.net/npm/types/fhirclient)
[![node](https://badgen.net/npm/node/fhirclient)](https://badgen.net/npm/node/fhirclient)
[![downloads](https://badgen.net/npm/dt/fhirclient)](https://www.npmtrends.com/fhirclient)


<br/><br/>


## Installation

### From NPM
```sh
npm i fhirclient
```
### From CDN
Include it with a `script` tag from one of the following locations:

From NPM Release:
- https://cdn.jsdelivr.net/npm/fhirclient/build/fhir-client.js
- https://cdn.jsdelivr.net/npm/fhirclient/build/fhir-client.min.js

Latest development builds from GitHub:
- https://combinatronics.com/smart-on-fhir/client-js/master/dist/build/fhir-client.js
- https://combinatronics.com/smart-on-fhir/client-js/master/dist/build/fhir-client.min.js


## Browser Usage

In the browser you typically have to create two separate pages that correspond to your
`launch_uri` (Launch Page) and `redirect_uri` (Index Page).

### As Library

```html
<!-- launch.html -->
<script src="./node_module/fhirclient/build/fhir-client.js"></script>
<script>
FHIR.oauth2.authorize({
    "client_id": "my_web_app",
    "scope": "patient/*.read"
});
</script>

<!-- index.html -->
<script src="./node_module/fhirclient/build/fhir-client.js"></script>
<script>
FHIR.oauth2.ready()
    .then(client => client.request("Patient"))
    .then(console.log)
    .catch(console.error);
</script>
```

### As Module
```js
import FHIR from "fhirclient"

// Launch Page
FHIR.oauth2.authorize({
    "client_id": "my_web_app",
    "scope": "patient/*.read"
});

// Index Page
FHIR.oauth2.ready()
    .then(client => client.request("Patient"))
    .then(console.log)
    .catch(console.error);
```

## Server Usage
The server is fundamentally different environment than the browser but the
API is very similar. Here is a simple Express example:
```js
const fhirClient = require("fhirclient");

// This is what the EHR will call
app.get("/launch", (req, res) => {
    fhirClient(req, res).authorize({
        "client_id": "my_web_app",
        "scope": "patient/*.read"
    });
});

// This is what the Auth server will redirect to
app.get("/", (req, res) => {
    fhirClient(req, res).ready()
        .then(client => client.request("Patient"))
        .then(res.json)
        .catch(res.json);
});
```


### [Read the full documentation](http://docs.smarthealthit.org/client-js/).

<br/>

## License
Apache 2.0

---
_Source: https://npm.io/package/fhirclient · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
