Frameworks - React
Adding Livecycle SDK to React application
In most React applications, Livecycle can simple by added to the root app and initialized using useEffect.
This should work for both SPA and SSR applications. (such as next.js or CRA)
Start by installing @livecycle/sdk
using your favorite package manager, and add the init logic as an effect in your root component.
Example
import React, { useEffect } from "react";
import ReactDOM from "react-dom";
import LivecycleSDK from "@livecycle/sdk"
ReactDOM.render(<App />, document.getElementById("root"));
import React, { useState } from 'react';
function App() {
useEffect(()=> {
LivecycleSDK.init().catch(console.error)
}, [])
return (
...
);
}