wolkenkit
Documentation
News
DocumentationReferenceBuilding a clientConnecting to an application

Connecting to an application

To connect to an application, you need to use the wolkenkit SDK. As it is a universal module, it works in the browser as well as in Node.js.

The wolkenkit SDK has been tested against Chrome 67.0+, Firefox 60.0+, Safari 11.1+, Microsoft Edge 17.0+, Internet Explorer 11.0, and Node.js 10.13.0+. Other platforms may work as well, they have just not been tested.

Installing the SDK

To install the wolkenkit SDK, use npm:

$ npm install wolkenkit-client@3.0.0

Polyfill old browsers

Please note that for Internet Explorer 11, you additionally need to install the module @babel/polyfill to make things work. For details on how to integrate this polyfill into your application, see its documentation.

Using the SDK

To use the SDK, call the require function to load the wolkenkit-client module:

const wolkenkit = require('wolkenkit-client');

In the browser

While Node.js supports the require function out of the box, you have to use a bundler such as webpack if you want to use the wolkenkit SDK inside an application that runs in the browser. For a simple example of how to set this up see the wolkenkit-client-template-spa-vanilla-js repository.

Connecting to an application

To connect to a wolkenkit application call the wolkenkit.connect function and provide the hostname of the server you want to connect to. Since this is an asynchronous function, you have to call it using the await keyword:

const app = await wolkenkit.connect({ host: 'local.wolkenkit.io' });

Setting the port

By default, the port 443 is being used. To change this, provide the port property as well:

const app = await wolkenkit.connect({ host: 'local.wolkenkit.io', port: 3000 });

Setting the protocol

There are two protocols that the wolkenkit SDK can use to connect to the wolkenkit application:

  • wss (default in the browser)
  • https (default on Node.js)
const app = await wolkenkit.connect({ host: 'local.wolkenkit.io', protocol: 'wss' });

Browsers are not yet ready for streaming

While the wss protocol makes use of web sockets, the https protocol uses streaming HTTP. Unfortunately, not all current browsers support streaming HTTP in a reasonable fashion. Hence, you may safely use wss on Node.js, but consider https to be experimental in the browser.