Skip to main content

usePersonalizationClient

The usePersonalizationClient hook provides low-level access to the PersonalizationClient instance. It is used to interact directly with the personalization logic, such as manual flag evaluation or state management. It works on the client as well as on the server.

import { usePersonalizationClient } from '@archibald/personalization';

const personalizationClient = usePersonalizationClient();

Return value

  • Type: PersonalizationClient

The PersonalizationClient instance manages the initialization of the personalization provider and provides methods for flag evaluation.

Example

import { useEffect } from 'react';
import { usePersonalizationClient } from '@archibald/personalization';

function ManualFlagCheck() {
const client = usePersonalizationClient();

useEffect(() => {
async function checkFlags() {
const flag = await client.getFeatureFlag('manual-check-flag');
console.log('Flag value:', flag.value);
}
checkFlags();
}, [client]);

return <div>Checking flag...</div>;
}