Utility Methods

We expose a few useful utility methods to aid referrer ID storage when operating in a browser context.

storeReferrer

import { storeReferrer } from '@chainvine/sdk';

storeReferrer(); //This will fetch the "r" query parameter from the current URL (if available) and store it in a CV_REF cookie

//You may customise the cookie settings as follows:

storeReferrer({
  durationDays: 30, //Override the default cookie duration (120 days)
  referrer: 'ABC123', //Should you already have access to the referrer, and if you do not want it fetched from the URL, you can provide it directly
}); 

getReferrer

import { getReferrer } from '@chainvine/sdk';

//Fetches a previously stored referrer from the CV_REF cookie if available, returns undefined if not
getReferrer(); 

clearReferrer

import { clearReferrer } from '@chainvine/sdk';

//Clear the CV_REF cookie:
clearReferrer();

Last updated