Use Hypertune outside of React
If you're using React or a React-based framework like Next.js, there may be cases when you need to use Hypertune outside the component tree.
In these cases, the useHypertune
hook is not available. Instead, use the generated getHypertuneSingleton
function:
import { getHypertuneSingleton } from '@/generated/hypertune.react'
export default function logSignUpEventOutsideOfReact() {
const hypertune = getHypertuneSingleton()
hypertune.signUp()
}
Prefer the useHypertune
hook whenever possible. Use getHypertuneSingleton
only when hooks cannot be used, e.g. in non-React utilities or event handlers outside the component tree.
Last updated