Client exports
Every export of the /client entry point for client components.
Import from @delmaredigital/payload-experiments/client. The module is marked 'use client'. Usage is described in Client counting.
| Export | Signature | Purpose |
|---|---|---|
ExperimentsProvider | ({ value: ClientAssignments, children }) | Provides assignments to hooks; records viewport exposures, pageviews and clicks |
useFlagPoint | useFlagPoint<P>(id) => { arm, params, source, experiment?, experimentId?, expose(renderedArm) } | Read an allow-listed flag point |
useExperiment | useExperiment<P>(slug) => { arm, params, expose(renderedArm) } | Read an allow-listed test |
ExperimentPageview | () | Records the pageview for whole-page tests on the current page |
ExperimentGroup | ({ expose?, children }) | Viewport exposure for a resolved Payload-blocks group |
trackConversionBeacon | (eventName, { idempotencyKey? }?) => void | Client conversion for a client-writable event source |
MAX_EVENTS_PER_BODY | 20 | Events per POST /xp/events body |
DEFAULT_MAX_BODY_BYTES | 8192 | Default events.maxBodyBytes |
ClientAssignments | type | The provider value |
Behaviour notes
- Hooks never record on read.
exposesends only for tests that use the manual policy, and only when the person is counted. - An id or slug missing from the provider's allow-list throws in development and returns the Original (
arm: 'control') with one console error in production. - Use one
apiRoutefor every provider on a page, including nested providers. - Viewport exposure watches a fixed, invisible 100 px marker at the top of the content and counts when at least half of it is visible, so short and tall content behave the same.
- Click and exposure beacons use
navigator.sendBeacon, with akeepalivefetch fallback.

