Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



73 Commits

Repository files navigation

SSB Client for React Native apps

Similar to ssb-client, but for React Native apps that run ssb-server using nodejs-mobile-react-native.



  • React Native 0.60 or higher
    • React Native 0.59 and lower are supported only in react-native-ssb-client version 5.0.0
  • nodejs-mobile-react-native as a dependency in your React Native project
  • react-native-ssb-shims as a dependency in your React Native project
npm install --save react-native-ssb-client


In your backend code (your nodejs-mobile project), make sure that you have ssb-server or secret-stack installed, and add the following configurations set up:

 const SecretStack = require('secret-stack');
 const ssbKeys = require('ssb-keys');
+const rnBridge = require('rn-bridge');
+const rnChannelPlugin = require('multiserver-rn-channel');
+const NoauthTransformPlugin = require('multiserver/plugins/noauth');

 const config = makeConfig('ssb', {
   connections: {
     incoming: {
       net: [{scope: 'private', transform: 'shs', port: 26831}],
+      channel: [{scope: 'device', transform: 'noauth'}],
     outgoing: {
       net: [{transform: 'shs'}],

+function rnChannelTransport(ssb: any) {
+  ssb.multiserver.transport({
+    name: 'channel',
+    create: () => rnChannelPlugin(,
+  });

+function noAuthTransform(ssb: any, cfg: any) {
+  ssb.multiserver.transform({
+    name: 'noauth',
+    create: () =>
+      NoauthTransformPlugin({
+        keys: {publicKey: Buffer.from(cfg.keys.public, 'base64')},
+      }),
+  });

 SecretStack({appKey: require('ssb-caps').shs})
+  .use(noAuthTransform)
+  .use(rnChannelTransport)
   .call(null, config);

In your frontend code we assume you have access to the muxrpc manifest object. Then, in your frontend code you import this library:

import ssbClient from 'react-native-ssb-client'

// ...

  .use(somePlugin) // optional
  .call(null, (err, ssb) => {
    // You can now use `ssb` with all the muxrpc APIs from the backend

NOTE! This library does not start the backend, you have to do that yourself by important nodejs-mobile-react-native and calling nodejs.start() or startProject().


  • ssbClient(manifest): this configures your muxrpc client, where manifest is an object describing the muxrpc APIs we want
  • .use(plugin): call this to attach a client-side plugin to your final muxrpc object. Plugins are {name, init} objects, where name is a string, and init(ssb): void is a function; much like secret-stack plugins are
  • .call(null, cb): call this to start using the muxrpc, it will be provided to you in the callback cb
  • .callPromise(): as an alternative to the above, you can call this to get a Promise that resolves with the muxrpc ssb object


When setting up the client, you can register plugins. These look and feel like ssb-server or secret-stack plugins, in fact, in many cases they are so similar that a plugin intended for ssb-server might work just fine for react-native-ssb-client!

You can use client-side plugins when you are sure you don't want to run this code in the backend. For instance, a client-side plugin is the perfect place to put a light cache, in order to avoid a request to the backend. See e.g. ssb-cached-about.

Below is a simple plugin that just publishes a greeting message in the DB:

const greeterPlugin = {
  name: 'greetings',

  init: function (ssb) {
    return {
      greet: (cb) => {
        ssb.publish({type: 'post', text: 'Hello world!'}, cb)

To install it:

+  .use(greeterPlugin)
   .call(null, (err, ssb) => {


To use it:

   .call(null, (err, ssb) => {
+    // Will publish a message on our feed:
+    ssb.greetings.greet((err, val) => { /* ... */ })


Some dependencies, such as events and assert, are in this library just to polyfill necessary Node.js utilities that are used in muxrpc and multiserver — important dependencies of this library.




ssb-client for React Native apps that use nodejs-mobile-react-native







No packages published