why deepstreamHub? compare us getting started feature roadmap faq
use cases pricing
products
developers
company
blog contact

deepstream can also be installed as an NPM package and offers a Node.js API to interact with it programmatically.

Node.js

This can be useful to build custom authentication or permissioning logic or if you want to use the server on top of a HTTP server like Express. You can view the full Node.js API here.

Install the server via npm

npm install deepstream.io

Create a js file, e.g. start.js with the following content

const DeepstreamServer = require('deepstream.io')
const C = DeepstreamServer.constants
/*
The server can take
1) a configuration file path
2) null to explicitly use defaults to be overriden by server.set()
3) left empty to load the base configuration from the config file located within the conf directory.
4) pass some options, missing options will be merged with the base configuration
*/
const server = new DeepstreamServer()

// start the server
server.start()

run the file with node

node start.js

Using the deepstream client in Node.js

The deepstream javascript client can be installed via NPM and used in Node.js.

npm install deepstream.io-client-js
const deepstream = require('deepstream.io-client-js')
const client = deepstream('localhost:6020').login()