helpful-carpenter-3208
fresh-football-47124
import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react"; const growthbook = new GrowthBook({ realtimeKey: "key_NNNN", trackingCallback: (experiment, result) => { // change to your tracking call: track("Experiment Viewed", { experimentId: experiment.key, variationId: result.variationId, }); }, }); //... inside of App: useEffect(() => { // Load feature definitions JSON from GrowthBook API fetch("<https://cdn.growthbook.io/api/features/key_NNNN>") .then((res) => res.json()) .then((json) => { growthbook.setFeatures(json.features); }) .catch(() => { console.log("Failed to fetch GrowthBook feature definitions"); }); }, [router.pathname]); // ... return ( <GrowthBookProvider growthbook={growthbook}> //... </GrowthBook>);
import { useFeature } from "@growthbook/growthbook-react"; //... const config = useFeature("somefeature-config").value;
Open source platform for stress free deployments, measured impact, and smarter decisions.