React Native SDK

Install

With npm:

npm install --save @front-finance/frontfinance-rn-sdk

With yarn:

yarn add @front-finance/frontfinance-rn-sdk

Getting connection link

The connection link for brokerage connection should be obtained from the Get catalog link endpoint. Request must be performed from the server side because it requires the client secret. You will get the response in the following format:

{
  "content": {
    "url": "https://web.getfront.com/broker-connect?auth_code={authCode}",
    "iFrameUrl": "https://web.getfront.com/b2b-iframe/{clientId}/broker-connect?auth_code={authCode}"
  },
  "status": "ok",
  "message": ""
}

You should use url from this response to run the FrontFinance component.

Using the FrontFinance component

import {
  FrontFinance,
  FrontPayload,
  TransferFinishedPayload
} from '@front-finance/frontfinance-rn-sdk'

// ...

<FrontFinance
  url={iFrameUrl}
    onBrokerConnected={(payload: FrontPayload) => {
      // use broker account data
    },
    onTransferFinished={(payload: TransferFinishedPayload) => {
      if (payload.status === 'success') {
        const successPayload = payload as TransferFinishedSuccessPayload

      } else {
        const errorPayload = payload as TransferFinishedErrorPayload        
     }
    },
    onClose={() =>
      // use close event
    },
    onError={(err: string) =>
      // use error message
    }
/>

ℹ️ See full source code example at example/App.tsx.

FrontFinance component arguments

keytypedescription
urlstringConnection link
onBrokerConnected(payload: FrontPayload) => voidCallback called when users connects their accounts
onTransferFinished(payload: TransferFinishedPayload) => voidCallback called when a crypto transfer is executed
onError(err: string) => void)Called if connection not happened. Returns an error message
onClose() => voidCalled at the end of the connection, or when user closed the connection page

Using tokens

You can use auth tokens to perform requests like get current balance, assets and execute transfers. Full API reference.

Typescript support

TypeScript definitions for @front-finance/frontfinance-rn-sdk are built into the npm package.