Rollout Using React Native SDK

Rollout enables you to release new features gradually and reduce risk. Instead of pushing updates to all users at once, you can use a feature flag to expose a new feature to a small segment, measure business impact, and then scale up safely. If anything goes wrong, do an instant rollback — no redeploy required.

This capability is powered by the Choose API using the Rollout selector. The call returns a variation that includes the following rolloutFlag conditions for each user:

  • rolloutFlag = true → user is included the rollout test and should see the new feature
  • rolloutFlag = false → user is in the rollout test but is assigned to the control group (feature off)
  • no flag returned → user isn’t included in the rollout campaign
🚧

Best practice

Put Rollout campaigns in a selector group, fetch all flag statuses at session start, and cache them for the session if they don’t change. Don’t mix campaign types in the same Choose call.

📘

For more information:

Code example

import { Page, choose } from '@dynamicyield/internal-react-native-sdk'; 

async function fetchRolloutFlags() { 
  await choose 
    .chooseVariations({ 
      page: Page.homePage({ location: 'ScreenName' }), 
      selectorNames: ['custom-json-campaign'], // or selectorGroups: ['feature_flags'] 
    }) 

    .then((result) => { 
      switch (result.status) { 
        case 'SUCCESS': 
        case 'WARNING': { 
          // Find the campaign by selector name (optional) 
          const choice = result.choices?.find( 
            (c) => c.name === 'custom-json-campaign' 
          ) ?? result.choices?.[0]; 

          const variation = choice?.variations?.[0]; 
          const data = variation?.payload?.data; 
          const rolloutFlag = variation?.rolloutFlag ?? false; 

          console.log(`selector=${choice?.name} rolloutFlag=${rolloutFlag ? 'true' : 'false'}`); 
          console.log('payloadData:', data); 
          break; 
        } 

        case 'ERROR': 
          // handle error 
          break; 
      } 
    }) 

    .catch((error) => { 
      // handle invalid params / transport errors 
      console.error('chooseVariations error', error); 
    }); 
}