Getting Started
First you need to get bee-js
into your project. This can be done using your favourite package management tool or directly:
- npm
- yarn
- script tag
npm install @ethersphere/bee-js --save
yarn add @ethersphere/bee-js --save
<script src="https://unpkg.com/@ethersphere/bee-js/dist/index.browser.min.js"></script>
After that you need to import the Bee class and create a bee instance connecting to your Bee node (here we assume it runs on localhost on default port). Be aware, if you will pass invalid URL the constructor will throw an exception!
import { Bee } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')
That’s it! now you can use the bee
object.
Run your own Bee node
You can find out more about running Bee node in the Bee docs
Using <script>
import
If you include bee-js
using the unpkg.com
script link then all the exported components will be available to you
under global namespace BeeJs
:
<script src="https://unpkg.com/@ethersphere/bee-js/dist/index.browser.min.js"></script>
<script>
const bee = new BeeJs.Bee('...')
</script>