Usage

Learn how to add the SDK and utilize its methods.

Setup

# npm
npm install @split-tech/browser-sdk
# yarn
yarn add @split-tech/browser-sdk

Initialize Split SDK

We propose two methods for integrating the Split SDK with your app, using your API key and any custom settings.

Using SplitBrowserProvider

Add a SplitBrowserProvider context at the top level, including the API key and custom options as props. Simply wrapping your app with this provider will automatically fetch user wallet information and connect the Split app.

Props

apiKey (*required﹒string)

A required string that authenticates the partner to the Split App. See More

config (*optional﹒SplitProviderConfig)

Settings include referralParam, which sets the query parameter name for the referral code. The default is "join", but it can be customized to fit your application's URL structure. Additionally, you can set the interval for refreshing wallet information, with a default time of 10 seconds. This ensures your app consistently updates with the latest information from the referee's wallet.


Using built-in functions.

Initialize the system at the top level and then register the user's wallet information within the desired components.

Methods

init(apiKey: string, config: SplitConfig)

It initializes your app with Split.

Parameters

apiKey (*required﹒string)

A required string that authenticates the partner to the Split App. See More

config (*optional﹒SplitConfig)

Settings include referralParam, which sets the query parameter name for the referral code. The default is "join", but it can be customized to fit your application's URL structure.

addReferral(refereeAddress: string)

It sends the referrer’s wallet address and the referee’s wallet address to Split. Based on this, Split will verify that the referrer logged into your app based on the referral link has performed the campaign(on-chain transaction) you specified in the Split Partner App.

Parameter

refereeAddress (*required﹒string)

A wallet address of referee.

Last updated