Native Communication

It's not possible to support all different APIs on all supported platforms. Sometimes you need to code in native.

Each platform can use different programming language. For instance on Android you can use Java or C.

You cannot call native methods directly from JavaScript, but you can achieve such communication creating a bridge.

Neft provides a module called native. Use it in your JavaScript code to send data and to receive it.

Native communication needs to be asynchronous and cannot block your execution.

In passing and receiving data you're limited to basic types:

Passing complex structures like arrays or objects is not supported, but you can parse it to JSON and send as a string.

Let's check, how we can communicate on different platforms:

JavaScript client

To send and receive native messages, use native module.

const { callNativeFunction, onNativeEvent } = Neft.native;
callNativeFunction("functionName", "arg1", "arg2", "argMore...");
onNativeEvent("eventName", (arg1, arg2, arg3) -> {});


Create a native/ios/CustomApp.swift file in your main application folder.

class CustomApp {
    init() {
        App.getApp().client.pushEvent("eventName", args: ["arg1", "arg2", CGFloat(2.4), nil])
        App.getApp().client.addCustomFunction("functionName") {
            (args: [Any?]) in ()


Create a native/android/ file in your main application folder.

package io.neft.customapp;

import io.neft.App;
import io.neft.utils.Consumer;

public class CustomApp {
    public CustomApp() {
        App.getInstance().getClient().pushEvent("eventName", "arg1", "arg2", 2.4f, null);
        App.getInstance().getClient().addCustomFunction("functionName", new Consumer<Object[]>() {
            public void accept(Object[] args) {}