Fast RPC based on TCP, WebSocket and MDSF
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
benchmark deps,lint: update eslint-config-metarhia Oct 2, 2018
bin deps,lint: update eslint-config-metarhia Aug 27, 2018
doc doc: update package name in documentation Sep 3, 2018
examples/readme-example lint: add comma-dangle rule to eslint Jul 20, 2017
lib lib: move RemoteError to es6 class Oct 18, 2018
test deps,lint: update eslint-config-metarhia Oct 2, 2018
tools deps,lint: update eslint-config-metarhia Oct 2, 2018
.appveyor.yml test: fix AppVeyor builds on Node.js 6 May 12, 2018
.babelrc build: tell Babel parser the correct source type Sep 5, 2018
.editorconfig Add .editorconfig Oct 13, 2016
.eslintignore doc: start working on new documentation Aug 17, 2017
.eslintrc lint,deps: move ESLint config to separate package Sep 8, 2017
.gitattributes dist: fix language statistics on GitHub Jun 22, 2017
.gitignore doc,deps: remove gitbook dependency May 16, 2018
.mailmap meta: update AUTHORS May 5, 2017
.npmignore npm: add development related files to .npmignore Aug 8, 2018
.remarkrc lint: revive markdown linting Sep 8, 2017
.travis.yml test: update Travis config to use the current Node Aug 7, 2018
AUTHORS meta: update AUTHORS Jul 4, 2018 Version 2.1.0 Oct 18, 2018 doc: fix linter errors in markdown files Sep 8, 2017
LICENSE meta: update year in LICENSE Jan 29, 2018 doc: update package name in documentation Sep 3, 2018
jstp.js build: use UMD for browser bundle Aug 6, 2018
package-lock.json deps,lint: update eslint-config-metarhia Oct 2, 2018
package.json deps,lint: update eslint-config-metarhia Oct 2, 2018
webpack.config.js lib,build: use Web Crypto API in browser Aug 8, 2018

Metarhia Logo

Travis CI AppVeyor CI Coverage Status NPM Version NPM Downloads/Month NPM Downloads

JSTP / JavaScript Transfer Protocol

JSTP is an RPC protocol and framework which provides two-way asynchronous data transfer with support of multiple parallel non-blocking interactions that is so transparent that an app may not even distinguish between local async functions and remote procedures.

And, as a nice bonus, there's a blazing fast JSON5 implementation bundled in!

This project is bound by a Code of Conduct.


JSTP works in Node.js and web browsers:

$ npm install --save @metarhia/jstp

Or, alternatively, there is jstp.umd.js UMD bundle.

We also have official client-side implementations for Swift and Java that work effortlessly on iOS and Android πŸŽ‰

Getting Started


'use strict';

const jstp = require('@metarhia/jstp');

// Application is the core high-level abstraction of the framework. An app
// consists of a number of interfaces, and each interface has its methods.
const app = new jstp.Application('testApp', {
  someService: {
    sayHi(connection, name, callback) {
      callback(null, `Hi, ${name}!`);

// Let's create a TCP server for this app. Other available transports are
// WebSocket and Unix domain sockets. One might notice that an array of
// applications is passed the `createServer()`. That's because it can serve
// any number of applications.
const server =[app]);
server.listen(3000, () => {
  console.log('TCP server listening on port 3000 πŸš€');


'use strict';

const jstp = require('@metarhia/jstp');

// Create a TCP connection to server and connect to the `testApp` application.
// Clients can have applications too for full-duplex RPC,
// but we don't need that in this example. Client is `null` in this example,
// this implies that username and password are both `null`
// here β€” that is, the protocol-level authentication is not leveraged in this
// example. The next argument is an array of interfaces to inspect and build
// remote proxy objects for. Remaining arguments are for
// net.connect (host and port) and last argument is a callback
// to be called on successful connection or error.
  'testApp', null, ['someService'], 3000, 'localhost', handleConnect

function handleConnect(error, connection, app) {
  if (error) {
    console.error(`Could not connect to the server: ${error}`);

  // The `app` object contains remote proxy objects for each interface that has
  // been requested which allow to use remote APIs as regular async functions.
  // Remote proxies are also `EventEmitter`s: they can be used to `.emit()`
  // events to another side of a connection and listen to them using `.on()`.
  app.someService.sayHi('JSTP', (error, message) => {
    if (error) {
      console.error(`Oops, something went wrong: ${error}`);
    console.log(`Server said "${message}" 😲`);

Project Maintainers

Kudos to @tshemsedinov for the initial idea and proof-of-concept implementation. Current project team is: