Skip to Content
Delmare Digital

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.

ExportSignaturePurpose
ExperimentsProvider({ value: ClientAssignments, children })Provides assignments to hooks; records viewport exposures, pageviews and clicks
useFlagPointuseFlagPoint<P>(id) => { arm, params, source, experiment?, experimentId?, expose(renderedArm) }Read an allow-listed flag point
useExperimentuseExperiment<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? }?) => voidClient conversion for a client-writable event source
MAX_EVENTS_PER_BODY20Events per POST /xp/events body
DEFAULT_MAX_BODY_BYTES8192Default events.maxBodyBytes
ClientAssignmentstypeThe provider value

Behaviour notes

  • Hooks never record on read. expose sends 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 apiRoute for 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 a keepalive fetch fallback.
Edit this page on GitHub

On this page