mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-03-15 15:30:49 +00:00
feat(docs): Add description how to set up JS Client for Node.js apps (#269)
This commit is contained in:
parent
40c881be5c
commit
96fa90affe
50
README.md
50
README.md
@ -3,12 +3,13 @@
|
|||||||
[](https://www.npmjs.com/package/@fluencelabs/js-client.api)
|
[](https://www.npmjs.com/package/@fluencelabs/js-client.api)
|
||||||
[](https://www.npmjs.com/package/@fluencelabs/js-client.web.standalone)
|
[](https://www.npmjs.com/package/@fluencelabs/js-client.web.standalone)
|
||||||
|
|
||||||
This is the Javascript client for the [Fluence](https://fluence.network) network.
|
This is the Javascript client for the [Fluence](https://fluence.network) network. The main role of the JS client is to connect to the Fluence Network and allow you to integrate Aqua code into your application.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
## Get Started
|
Adding the Fluence JS client for your web application is very easy.
|
||||||
|
|
||||||
Adding the Fluence JS client for your web application is very easy:
|
### Browser-based Apps
|
||||||
|
|
||||||
1. Add a script tag with the JS Client bundle to your `index.html`. The easiest way to do this is using a CDN (like [JSDELIVR](https://www.jsdelivr.com/) or [UNPKG](https://unpkg.com/)). The script is large, thus we highly recommend to use the `async` attribute.
|
1. Add a script tag with the JS Client bundle to your `index.html`. The easiest way to do this is using a CDN (like [JSDELIVR](https://www.jsdelivr.com/) or [UNPKG](https://unpkg.com/)). The script is large, thus we highly recommend to use the `async` attribute.
|
||||||
|
|
||||||
@ -16,13 +17,15 @@ Adding the Fluence JS client for your web application is very easy:
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<head>
|
<head>
|
||||||
<title>Cool App</title>
|
<title>Cool App</title>
|
||||||
<script src='https://cdn.jsdelivr.net/npm/@fluencelabs/js-client.web.standalone@0.10.0/dist/js-client.min.js'
|
<script
|
||||||
async></script>
|
src="https://cdn.jsdelivr.net/npm/@fluencelabs/js-client.web.standalone@0.13.3/dist/js-client.min.js"
|
||||||
|
async
|
||||||
|
></script>
|
||||||
</head>
|
</head>
|
||||||
```
|
```
|
||||||
|
|
||||||
If you cannot or don't want to use a CDN, feel free to get the script directly from the `npm` package and host in yourself: `https://www.npmjs.com/package/@fluencelabs/js-client.web.standalone`. You can find the script in the `/dist` directory of the package. (Note: this option means that developers understand what they are doing and know how to serve this file from their own web server.)
|
If you cannot or don't want to use a CDN, feel free to get the script directly from the [npm package](https://www.npmjs.com/package/@fluencelabs/js-client.web.standalone) and host it yourself. You can find the script in the `/dist` directory of the package. (Note: this option means that developers understand what they are doing and know how to serve this file from their own web server.)
|
||||||
|
|
||||||
2. Install the following packages:
|
2. Install the following packages:
|
||||||
|
|
||||||
@ -34,14 +37,30 @@ Adding the Fluence JS client for your web application is very easy:
|
|||||||
|
|
||||||
```
|
```
|
||||||
import { Fluence } from "@fluencelabs/js-client.api";
|
import { Fluence } from "@fluencelabs/js-client.api";
|
||||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
import { randomKras } from '@fluencelabs/fluence-network-environment';
|
||||||
|
|
||||||
Fluence.start({
|
Fluence.connect(randomKras());
|
||||||
relay: krasnodar[3],
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use Aqua in a Web Application
|
### Node.js Apps
|
||||||
|
|
||||||
|
1. Install the following packages:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm i @fluencelabs/js-client.api"@fluencelabs/js-client.node @fluencelabs/fluence-network-environment
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Add the following lines at the beginning of your code:
|
||||||
|
|
||||||
|
```
|
||||||
|
import '@fluencelabs/js-client.node';
|
||||||
|
import { Fluence } from "@fluencelabs/js-client.api";
|
||||||
|
import { randomKras } from '@fluencelabs/fluence-network-environment';
|
||||||
|
|
||||||
|
Fluence.connect(randomKras());
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage in an Application
|
||||||
|
|
||||||
Once 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/fluence-cli).
|
Once 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/fluence-cli).
|
||||||
|
|
||||||
@ -100,23 +119,18 @@ Once you've added the client, you can compile [Aqua](https://github.com/fluencel
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Warning**: Fluence JS client for Node.js is currently broken. We will fix this shortly.
|
|
||||||
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
To hack on the Fluence JS Client itself, please refer to the [development page](./DEVELOPING.md).
|
To hack on the Fluence JS Client itself, please refer to the [development page](./DEVELOPING.md).
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
The starting point for all documentation related to Fluence is
|
The starting point for all documentation related to Fluence is
|
||||||
[fluence.dev](https://fluence.dev/). We also have an active [YouTube channel](https://www.youtube.com/@fluencelabs).
|
[fluence.dev](https://fluence.dev/). We also have an active [YouTube channel](https://www.youtube.com/@fluencelabs).
|
||||||
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
Please, file an [issue](https://github.com/fluencelabs/fluence-js/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.
|
Please, file an [issue](https://github.com/fluencelabs/js-client/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user