Installation

With npm:

npm install --save @meshconnect/react-native-link-sdk

With yarn:

yarn add @meshconnect/react-native-link-sdk

💡 This package requires react-native-webview to be installed in your project. Although it is listed as direct dependency, some times it is not installed automatically (This is a known npm issue). You should install it manually via following command in this case:

npm install --save react-native-webview

# or with yarn
yarn add react-native-webview

Link token should be obtained from the POST /api/v1/linktoken endpoint. API reference for this request is available here. The request must be performed from the server side because it requires the client’s secret. You will get the response in the following format:

{
  "content": {
    "linkToken": "{linkToken}"
  },
  "status": "ok",
  "message": ""
}
import React from 'react';
import {
  LinkConnect,
  LinkPayload,
  TransferFinishedPayload,
  TransferFinishedSuccessPayload,
  TransferFinishedErrorPayload
} from '@meshconnect/react-native-link-sdk';

export const App = () => {
  return (
    <LinkConnect
      linkToken={"YOUR_LINKTOKEN"}
      onIntegrationConnected={(payload: LinkPayload) => {
        // use broker account data
      }}
      onTransferFinished={(payload: TransferFinishedPayload) => {
        if (payload.status === 'success') {
          const successPayload = payload as TransferFinishedSuccessPayload
          // use transfer finished data
        } else {
          const errorPayload = payload as TransferFinishedErrorPayload
          // handle transfer error
        }
      }}
      onExit={(err?: string) => {
        // use error message
      }}
      onEvent={(event: string, payload: LinkPayload) => {
        // use event
      }}
    />
  )
}

export default App;

ℹ️ See full source code example at examples/.

LinkConnect component arguments

KeyTypeRequired/Optional
linkTokenstringrequired
onIntegrationConnected(payload: LinkPayload) => voidoptional
onTransferFinished(payload: TransferFinishedPayload) => voidoptional
onExit(err: string) => void)optional

Typescript support

Typescript definitions for @meshconnect/react-native-link-sdk are built into the npm package.