Skip to content

Commit

Permalink
docs: detail how to reference on a cdn (#2271)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckniffen committed Apr 12, 2023
1 parent d2224e9 commit 4ffc51a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ It goes through:

If you're using xrpl.js with React or Deno, you'll need to do a couple extra steps to set it up:

- [Using xrpl.js with a CDN](./UNIQUE_SETUPS.md#using-xrpljs-from-a-cdn)
- [Using xrpl.js with `create-react-app`](./UNIQUE_SETUPS.md#using-xrpljs-with-create-react-app)
- [Using xrpl.js with `React Native`](./UNIQUE_SETUPS.md#using-xrpljs-with-react-native)
- [Using xrpl.js with `Vite React`](./UNIQUE_SETUPS.md#using-xrpljs-with-vite-react)
Expand Down
9 changes: 9 additions & 0 deletions UNIQUE_SETUPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

For when you need to do more than just install `xrpl.js` for it to work (especially for React projects in the browser).

### Using xrpl.js from a CDN

You can avoid setting up your build system to handle `xrpl.js` by using a cdn version that is prebuilt for the browser.

- unpkg `<script src="https://unpkg.com/xrpl@2.3.0/build/xrpl-latest-min.js"></script>`
- jsdelivr `<script src="https://cdn.jsdelivr.net/npm/xrpl@2.3.0/build/xrpl-latest-min.js"></script>`

Ensure that the full path is provided so the browser can find the sourcemaps.

### Using xrpl.js with `create-react-app`

To use `xrpl.js` with React, you need to install shims for core NodeJS modules. Starting with version 5, Webpack stopped including shims by default, so you must modify your Webpack configuration to add the shims you need. Either you can eject your config and modify it, or you can use a library such as `react-app-rewired`. The example below uses `react-app-rewired`.
Expand Down

0 comments on commit 4ffc51a

Please sign in to comment.