aboutsummaryrefslogtreecommitdiffstats
path: root/docs/cookbook
diff options
context:
space:
mode:
authorkarissa <krmckelv@gmail.com>2017-03-16 10:58:48 +0100
committerkarissa <krmckelv@gmail.com>2017-03-16 10:58:48 +0100
commit8fd05ac298072a08f5d984691f156fb94a1d253f (patch)
tree9bbc5a38c92a93fc66e584a0e1558ccb305ef6a1 /docs/cookbook
parentb6d28f691170c6b0fbc774af23b4d82ace7a2558 (diff)
downloaddat-docs-8fd05ac298072a08f5d984691f156fb94a1d253f.tar.gz
dat-docs-8fd05ac298072a08f5d984691f156fb94a1d253f.zip
add dat.min.js script
Diffstat (limited to 'docs/cookbook')
-rw-r--r--docs/cookbook/browser.md28
1 files changed, 25 insertions, 3 deletions
diff --git a/docs/cookbook/browser.md b/docs/cookbook/browser.md
index b1853e8..62835f6 100644
--- a/docs/cookbook/browser.md
+++ b/docs/cookbook/browser.md
@@ -8,11 +8,33 @@ Because dat-js uses webrtc, it can only connect to other browser clients. It is
OK, now for the goods.
-## Creating a dat
+## Install
-```js
+Embed the following script [dat.min.js](https://raw.githubusercontent.com/datproject/dat-js/master/dat.min.js) on the page:
+```
+<script type="text/javascript" src="dat.min.js"></script>
+```
+This provides a `Dat` prototype on the `window` object.
+
+### Browserify
+
+Or use Node.js in the browser with [browserify](http://github.com/substack/node-browserify), which lets you use node.js style require() to organize your browser code using npm.
+
+```
+npm install dat-js
+```
+
+Then use `dat-js` like this:
+
+```
var Dat = require('dat-js')
+```
+## Quick Examples
+
+### Sharing data
+
+```js
var dat = Dat()
dat.add(function (repo) {
var writer = repo.archive.createFileWriteStream('hello.txt')
@@ -21,7 +43,7 @@ dat.add(function (repo) {
})
```
-## Downloading data
+### Downloading data
```js
var Dat = require('dat-js')