Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ This SDK can be used either in NodeJS or in a browser.
npm install kuzzle-sdk --save
```

### Javascript

Clone this github repository and run ``npm run build``. A ``dist`` directory will be created, containing a browser version of this SDK.
### Browser

To run the SDK in the browser, you need to pick the [built version available here](https://raw.githubusercontent.com/kuzzleio/sdk-javascript/master/dist/kuzzle.js). You can also build it yourself by cloning this repository and running `npm run build`. A `dist` directory will be created, containing a browser version of this SDK.

```html
<script type="text/javascript" src="dist/kuzzle.js"></script>
```

The browser version is also available from CDN:

```html
Expand All @@ -81,6 +79,23 @@ If you want to support older browser versions, you may load `socket.io` before K
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.slim.js"></script>
```

#### Browser with Webpack

If you use Webpack, you'll likely use the NPM-packaged version of the SDK (like in Node)

```
npm install kuzzle-sdk --save
```

But you'll still need to pick the built version (which ships with the package).

```javascript
// with the classic require...
let Kuzzle = require('kuzzle-sdk/dist/kuzzle.js')
// ... or with the new import directive.
import Kuzzle from 'kuzzle-sdk/dist/kuzzle.js'
```

## License

[Apache 2](LICENSE.md)
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ var
// Adds on the fly methods promisification
Kuzzle.prototype.bluebird = bluebird;

if (typeof window !== 'undefined' && typeof BUILT === 'undefined') {
throw new Error('It looks like you are using the Nodejs version of Kuzzle SDK ' +
'in a browser. ' +
'It is strongly recommended to use the browser-specific build instead. ' +
'Learn more at https://github.com/kuzzleio/sdk-javascript/tree/master#browser');
}

module.exports = Kuzzle;
Loading