diff --git a/CHANGELOG.md b/CHANGELOG.md index eb14f63f..6d79a813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 9.0.0 - 2025-xx-xx +### Added +- Add minimal support for React Native. + - Add `react-native` section to `package.json`. + - Add instructions to `README.md`. + ### Changed - **BREAKING**: Drop support for Node.js < 18. - **BREAKING**: Upgrade dependencies. diff --git a/README.md b/README.md index 1b894236..b3052a99 100644 --- a/README.md +++ b/README.md @@ -350,6 +350,22 @@ The `safe` options flag set to `true` enables this behavior: const expanded = await jsonld.expand(data, {safe: true}); ``` +### Using with React Native + +Using this library with React Native requires a polyfill such as +[`data-integrity-rn`](https://github.com/digitalcredentials/data-integrity-rn) +to be imported before this library: + +```js +import '@digitalcredentials/data-integrity-rn' +import * as jsonld from 'jsonld' +``` + +The polyfill needs to provide the following globals: + +* `crypto.subtle` +* `TextEncoder` + Tests ----- diff --git a/package.json b/package.json index 14fbbe4d..2cbbf6a0 100644 --- a/package.json +++ b/package.json @@ -119,5 +119,15 @@ "request": false, "url": false, "util": false + }, + "react-native": { + "./lib/index.js": "./lib/jsonld.js", + "./lib/platform.js": "./lib/platform-browser.js", + "crypto": false, + "http": false, + "jsonld-request": false, + "request": false, + "url": false, + "util": false } }