Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 1fb71f2

Browse files
committed
docs: usage clarifications
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 3caa1eb commit 1fb71f2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,24 @@ This project is tested on OSX & Linux, expected to work on Windows.
103103

104104
### Use in Node.js
105105

106-
To include this project programmatically:
106+
To create an IPFS node programmatically:
107107

108108
```js
109109
const IPFS = require('ipfs')
110110
const node = new IPFS()
111+
112+
node.on('ready', () => {
113+
// Ready to use!
114+
// See https://github.com/ipfs/js-ipfs#core-api
115+
})
111116
```
112117

113118
### Through command line tool
114119

115120
In order to use js-ipfs as a CLI, you must install it with the `global` flag. Run the following (even if you have ipfs installed locally):
116121

117122
```bash
118-
> npm install ipfs --global
123+
npm install ipfs --global
119124
```
120125

121126
The CLI is available by using the command `jsipfs` in your terminal. This is aliased, instead of using `ipfs`, to make sure it does not conflict with the [Go implementation](https://github.com/ipfs/go-ipfs).
@@ -136,7 +141,19 @@ You can also load it using a `<script>` using the [unpkg](https://unpkg.com) CDN
136141
<script src="https://unpkg.com/ipfs/dist/index.js"></script>
137142
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.js"></script>
138143
```
139-
Inserting one of the above lines will make an `Ipfs` object available in the global namespace.
144+
145+
Inserting one of the above lines will make an `Ipfs` object available in the global namespace:
146+
147+
```html
148+
<script>
149+
const node = new window.Ipfs()
150+
151+
node.on('ready', () => {
152+
// Ready to use!
153+
// See https://github.com/ipfs/js-ipfs#core-api
154+
})
155+
</script>
156+
```
140157

141158
## Usage
142159

0 commit comments

Comments
 (0)