React
Installation
To use Rollee Connect with React, you must create a React project first:
npx create-react-app your-rollee-connect-app
Afterwards, you need to install the Rollee Connect SDK library in your project.
$ npm i @getrollee/connect-react-sdk
Usage
Now, you must import the Rollee Connect component and place it in your App's code.
The RolleeConnect component is a View that you can integrate into your App's flow, and the production
and customizationId
are optional as well as callback handlers are passed in as props
import RolleeView from '@getrollee/connect-react-sdk';
.
.
.
<RolleeView config={CONFIG} onClose={onClose} onCompleted={onCompleted} onLoginSuccess={onLoginSuccess} onAnalytics={onAnalytics} />
Callbacks
When you want to exit from Rollee Connect back to your application or to get information when user completed flow, you should use onClose
, onCompleted
or onLoginSuccess
callbacks
function onLoginSuccess(data) {
console.log('onLoginSuccess', data);
}
function onCompleted(data) {
console.log('onCompleted', data);
}
function onClose() {
console.log('onClose');
}
Configuration
To define a User Session on Rollee Connect, you must provide the mandatory parameter sessionToken
.
The production
and customizationId
parameters are optional.
▫️ The minimal configuration for setting up RolleeConnect component:
const CONFIG = {
sessionToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
};
▫️ The optional configuration for setting up Rollee Connect component:
const CONFIG = {
sessionToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
production: false,
customizationId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
};
// If you wish not to customize production and customizationId params, you can just delete them and the SDK will use the respective default value.
Running the SDK in the Production environment
By default, Rollee Connect runs in the Sandbox environment, meant for testing.
To be able to test SDK in the Production environment, you should provide a setup parameter named production and set it to true.
const CONFIG = {
sessionToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
production: true,
};
Setup Parameters Descriptions
Bellow you have the description of all the parameters present in the Setup.
If you wish not to customise one of the parameters present in setup
, you can just delete them and the SDK will use the respective default value.
Param | Description |
---|---|
sessionToken | String - defining user session on Rollee Connect application |
production | Boolean - optional parameter for switching between sandbox and production env |
customizationId | String - optional parameter for adding customization defined in Rollee Dashboard |
Example file
In order to quickstart your Rollee Connect experience with React, you can simply replace your App.js file with the following file. Please update the token and sessionToken values accordingly.
import './App.css';
import RolleeView from '@getrollee/connect-react-sdk';
function App() {
const CONFIG = {
sessionToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
}
function onLoginSuccess(data) {
console.log('onLoginSuccess', data);
}
function onAnalytics(data) {
console.log('onAnalytics',data);
}
function onCompleted(data) {
console.log('onCompleted', data);
}
function onClose() {
console.log('onClose');
}
return (
<div className="App">
<header className="header">
<h1>Rollee React SDK</h1>
</header>
<RolleeView config={CONFIG} onClose={onClose} onCompleted={onCompleted} onLoginSuccess={onLoginSuccess} onAnalytics={onAnalytics} />
</div>
);
}
export default App;
Updated about 2 months ago