Skip to content

Commit ded42f7

Browse files
committed
Add minimal support for React Native.
- Add `react-native` section to `package.json`. - Add instructions to `README.md`.
1 parent f2d39a1 commit ded42f7

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## 9.0.0 - 2025-xx-xx
44

5+
### Added
6+
- Add minimal support for React Native.
7+
- Add `react-native` section to `package.json`.
8+
- Add instructions to `README.md`.
9+
510
### Changed
611
- **BREAKING**: Drop support for Node.js < 18.
712
- **BREAKING**: Upgrade dependencies.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,22 @@ The `safe` options flag set to `true` enables this behavior:
350350
const expanded = await jsonld.expand(data, {safe: true});
351351
```
352352

353+
### Using with React Native
354+
355+
Using this library with React Native requires a polyfill such as
356+
[`data-integrity-rn`](https://github.com/digitalcredentials/data-integrity-rn)
357+
to be imported before this library:
358+
359+
```js
360+
import '@digitalcredentials/data-integrity-rn'
361+
import * as jsonld from 'jsonld'
362+
```
363+
364+
The polyfill needs to provide the following globals:
365+
366+
* `crypto.subtle`
367+
* `TextEncoder`
368+
353369
Tests
354370
-----
355371

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,15 @@
119119
"request": false,
120120
"url": false,
121121
"util": false
122+
},
123+
"react-native": {
124+
"./lib/index.js": "./lib/jsonld.js",
125+
"./lib/platform.js": "./lib/platform-browser.js",
126+
"crypto": false,
127+
"http": false,
128+
"jsonld-request": false,
129+
"request": false,
130+
"url": false,
131+
"util": false
122132
}
123133
}

0 commit comments

Comments
 (0)