useCroct

Provide access to the SDK instance.

This hook gets the instance of the SDK initialized by the <CroctProvider> component, providing access to the  Plug API.

Signature

This hook has the following signature:

function useCroct(): Plug;

The return is the  Plug instance.

Example

Here is an example of how to use this hook:

Hero.jsx
12345678910111213
import {useCroct} from '@croct/plug-next';
export function SignupButton() {
const croct = useCroct();
function onClick() {
croct.track('goalCompleted', {
goalId: 'ctaClicked',
});
}
return (<a href="/signup" onClick={onClick}>Sign up</a>);
}