Update README to include unpkg example

This commit is contained in:
Franck Royer 2021-10-12 16:29:52 +11:00
parent 0d86c91720
commit 9a8ecd8611
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 33 additions and 2 deletions

View File

@ -32,11 +32,42 @@ Install `js-waku` package:
npm install js-waku
```
### Import js-waku
To use js-waku in your application, you can:
use `import`:
```js
import { Waku } from 'js-waku';
const waku = await Waku.create();
```
use `require`:
```js
const jsWaku = require('js-waku');
jsWaku.Waku.create().then(waku => {
// ...
});
```
Or directly import it in a `<script>` tag:
```html
<script src='https://unpkg.com/js-waku@0.14.0-rc.0/build/umd/js-waku.min.bundle.js'></script>
<script>
jswaku.Waku.create().then(waku => {
// ...
}
</script>
```
### Start a waku node
```ts
import { Waku } from 'js-waku';
const waku = await Waku.create({ bootstrap: true });
```