@@ -25,41 +25,34 @@ This is the Javascript client for the [Fluence](https://fluence.network) network
2525
2626### HTML page
2727
28- Add a script tag with the JS Client bundle to your ` index.html ` . The easiest way to do this is using a CDN (
28+ Add a script tag with the JS Client module to your ` index.html ` . The easiest way to do this is using a CDN (
2929like [ JSDELIVR] ( https://www.jsdelivr.com/ ) or [ UNPKG] ( https://unpkg.com/ ) ).
3030
3131Here is an example using the JSDELIVR CDN:
3232
3333``` html
3434<head >
3535 <title >Cool App</title >
36- <script src =" https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/browser/index.min.js" ></script >
36+ <script
37+ type =" module"
38+ src =" https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/browser/index.min.js"
39+ ></script >
40+ <script type =" module" >
41+ import {
42+ Fluence ,
43+ randomKras ,
44+ } from " https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/browser/index.min.js" ;
45+
46+ Fluence .connect (randomKras ());
47+ </script >
3748</head >
3849```
3950
4051If you cannot or don't want to use a CDN, feel free to get the script directly from
4152the [ npm package] ( https://www.npmjs.com/package/@fluencelabs/js-client ) and host it yourself. You can find the script in
42- the ` /dist ` directory of the package. (Note: this option means that developers understand what they are doing and know
53+ the ` /dist/browser ` directory of the package. (Note: this option means that developers understand what they are doing and know
4354how to serve this file from their own web server.)
4455
45- After importing JS-client to HTML page the client is available as ` window.Fluence ` variable.
46- To get a specific network you can peek at
47-
48- ```
49- https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/network.js
50- ```
51-
52- and hardcode selected network. So initialization would look like this
53-
54- ``` javascript
55- // Passing 1 kras network config from ./dist/network.js above
56- window .Fluence .connect ({
57- multiaddr:
58- " /dns4/0-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" ,
59- peerId: " 12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" ,
60- });
61- ```
62-
6356## Usage in an Application
6457
6558Once you've added the client, you can compile [ Aqua] ( https://github.com/fluencelabs/aqua ) and run it in your application. To compile Aqua, use [ Fluence CLI] ( https://github.com/fluencelabs/cli ) .
0 commit comments