yarn add @caast/react-use-caast
# or
npm i @caast/react-use-caast --save
This hook allow you to simply implement Caast library on a React project. It will inject the library in your DOM with your provided API keys. The caast instance will then be available in order to perform the available actions of the library.
import React, { useState, useEffect } from 'react';
import useCaast from '@caast/react-use-caast';
export default function App() {
const caastInstance = useCaast({ app_id: 'MY_APP_ID', app_key: 'MY_APP_KEY' });
useEffect(() => {
if (caastInstance) {
console.log('Caast is now loaded, you can now call Caast library methods', caastInstance.infos());
}
}, [caastInstance]);
}