UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

34 lines (33 loc) 1.3 kB
/** * Hook for accessing Statsig experiments with type-safe fallback values. * * Unlike feature gates and dynamic configs, experiments don't have a base configuration * with overrides. Instead, they have multiple horizontal variations. Because of this, * you must provide a fallback value and can optionally specify the return type. * * @example * // Basic usage (returns string by default) * const buttonColor = useExperiment('button-color-test', 'value', 'blue') * * @example * // With explicit type parameter * interface ButtonConfig { * color: string * size: 'small' | 'medium' | 'large' * } * const config = useExperiment<ButtonConfig>( * 'button-experiment', * 'config', * { color: 'blue', size: 'medium' } * ) * * @example * // Getting a specific parameter * const variant = useExperiment('checkout-flow-test', 'variant', 'control') * * @param experimentName - The name of the experiment in Statsig * @param parameterName - The name of the parameter to get from the experiment * @param fallback - The fallback value to use when the experiment/parameter is not available * @returns The experiment parameter value with the specified type */ export declare function useExperiment<T = string>(experimentName: string, parameterName: string, fallback: T): T;