# @bedrock/jsonld-document-loader

> A document loader for jsonld.js.

Latest version **5.2.1** (published 2025-12-11) · SEE LICENSE IN LICENSE.md license · 0 weekly downloads

## Install

```sh
npm install @bedrock/jsonld-document-loader
pnpm add @bedrock/jsonld-document-loader
yarn add @bedrock/jsonld-document-loader
bun add @bedrock/jsonld-document-loader
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.2.1 |
| Published | 2025-12-11 |
| First published | 2022-04-01 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE.md |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Digital Bazaar, Inc. |
| Maintainers | msporny, dlongley, davidlehn, gannan |
| Keywords | bedrock, jsonld, document loader |

## Links

- npm: https://www.npmjs.com/package/@bedrock/jsonld-document-loader
- Repository: https://github.com/digitalbazaar/bedrock-jsonld-document-loader
- Issues: https://github.com/digitalbazaar/bedrock-jsonld-document-loader/issues
- npm.io page: https://npm.io/package/@bedrock/jsonld-document-loader

## Dependencies (2)

- [jsonld-document-loader](https://npm.io/package/jsonld-document-loader.md) ^2.3.0
- [@digitalbazaar/http-client](https://npm.io/package/@digitalbazaar/http-client.md) ^4.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 5.2.1 (latest) — 2025-12-11
- 5.2.0 — 2025-01-30
- 5.1.0 — 2024-07-31
- 5.0.0 — 2024-03-17
- 4.0.0 — 2023-09-18
- 3.0.0 — 2022-04-29
- 2.0.2 — 2022-04-01
- 2.0.1 — 2022-04-01
- 2.0.0 — 2022-04-01

## README

# JSON-LD Document Loader _(@bedrock/jsonld-document-loader)_

[![Build Status](https://img.shields.io/github/workflow/status/digitalbazaar/bedrock-jsonld-document-loader/Node.js%20CI)](https://github.com/digitalbazaar/bedrock-jsonld-document-loader/actions?query=workflow%3A%22Node.js+CI%22)
[![NPM Version](https://img.shields.io/npm/v/bedrock-jsonld-document-loader.svg)](https://npm.im/bedrock-jsonld-document-loader)

> A document loader API for jsonld.js and the Bedrock ecosystem.

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [Commercial Support](#commercial-support)
- [License](#license)

## Install

- Node.js 14+ is required.

### NPM

To install via NPM:

```sh
npm install --save @bedrock/jsonld-document-loader
```

### Development

To install locally (for development):

```sh
git clone https://github.com/digitalbazaar/bedrock-jsonld-document-loader.git
cd bedrock-jsonld-document-loader
npm install
```

## Usage

This library exports the following things:

1. A `jsonLdDocumentLoader` instance.
2. A default `documentLoader` function (with an instance bound to it).
3. An `httpClientHandler`, for use with `cfg.documentLoader.mode === 'web'`.

```js
import {documentLoader} from '@bedrock/jsonld-document-loader';
```

### Enabling the HTTP/HTTPS protocol handler

```js
import * as bedrock from '@bedrock/core';
const {config: {'your-project': cfg}} = bedrock;

// Import the loader instance, and not the 'documentLoader' function directly.
import {jsonLdDocumentLoader, httpClientHandler} from
  '@bedrock/jsonld-document-loader';

// if enabled, add loader for remote documents
if(cfg.documentLoader.mode === 'web') {
  jsonLdDocumentLoader.setProtocolHandler({protocol: 'http', handler: httpClientHandler});
  jsonLdDocumentLoader.setProtocolHandler({protocol: 'https', handler: httpClientHandler});
}

export const documentLoader = jsonLdDocumentLoader.build();
```

## Contribute

See [the contribute file](https://github.com/digitalbazaar/bedrock/blob/master/CONTRIBUTING.md)!

PRs accepted.

If editing the Readme, please conform to the
[standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## Commercial Support

Commercial support for this library is available upon request from
Digital Bazaar: support@digitalbazaar.com

## License

[Bedrock Non-Commercial License v1.0](LICENSE.md) © Digital Bazaar

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