Use CasesProduction Ready

Real-World Use Cases

Two common scenarios from banking and enterprise: giving early access to specific people, and rolling out features progressively by branch or region.

In this guide

  1. 1. Family & Friends Program— Early access for specific users via list-based segments
  2. 2. Branch-by-Branch Rollout— Gradual rollout by branch or region using rule-based targeting

1. Family & Friends Program

Scenario

You're a bank launching a new mobile payment feature. Before rolling it out to all 500,000 customers, you want to test it with a small group of trusted people: employees, partners, and select customers.

👥

Who

50 employees + 20 partner contacts + 30 VIP customers

🎯

Goal

Validate the feature with real users before general availability

🔒

Requirement

Only whitelisted users see the feature, everyone else gets the old flow

Step 1: Create a List-Based Segment

In the Rollgate dashboard, go to Segments and create a new segment of type List-Based. Name it something like “Family & Friends”.

Then add the user IDs of your trusted testers. You can paste them comma-separated or one per line:

User IDs to add
emp-marco-rossi, emp-giulia-bianchi, emp-luca-ferrari
partner-acme-001, partner-globex-042
vip-customer-1001, vip-customer-1002, vip-customer-1003

Step 2: Create the Feature Flag

Create a boolean flag called mobile-payments-v2. Set the global rollout to 0% (nobody sees it by default).

Step 3: Add a Targeting Rule

In the flag's targeting section, add a rule with the condition User is in segment “Family & Friends”. Set the rule rollout to 100%.

Now the flag is enabled only for users in that segment. Global rollout stays at 0%, so nobody else sees the feature.

Step 4: Integrate in Your App

React - Mobile Payments Feature
import { RollgateProvider, useFlag } from '@rollgate/sdk-react';

function App() {
  return (
    <RollgateProvider
      apiKey="YOUR_CLIENT_KEY"
      user={{
        id: currentUser.id,        // e.g. "emp-marco-rossi"
        attributes: {
          role: currentUser.role,   // "employee", "partner", "customer"
          branch: currentUser.branch,
        },
      }}
    >
      <PaymentsPage />
    </RollgateProvider>
  );
}

function PaymentsPage() {
  const mobilePayments = useFlag('mobile-payments-v2', false);

  if (mobilePayments) {
    return <MobilePaymentsV2 />;
  }

  return <ClassicPayments />;
}
Node.js - Server-Side Check
import { RollgateClient } from '@rollgate/sdk-node';

const rollgate = new RollgateClient({
  apiKey: process.env.ROLLGATE_SERVER_KEY,
  enableStreaming: true,
});

await rollgate.init();

app.get('/api/payments/methods', async (req, res) => {
  const user = await getAuthenticatedUser(req);

  const showV2 = rollgate.isEnabled('mobile-payments-v2', false, {
    userId: user.id,
    attributes: { role: user.role, branch: user.branchCode },
  });

  if (showV2) {
    return res.json(await getMobilePaymentMethods(user));
  }

  return res.json(await getClassicPaymentMethods(user));
});

Workflow Summary

  1. 1. Create list-based segment with trusted user IDs
  2. 2. Create flag with 0% global rollout
  3. 3.Add targeting rule: “User in segment” → 100% rollout
  4. 4.Test with Family & Friends group
  5. 5.When ready, increase global rollout to 10% → 50% → 100%
  6. 6. Remove the flag from code once fully rolled out

2. Branch-by-Branch Rollout

Scenario

Your bank has 200+ branchesacross the country. You're launching a redesigned account opening flow and want to roll it out progressively: start with 3 pilot branches, then expand region by region.

🏢

Phase 1

3 pilot branches in Milan

🌎

Phase 2

All branches in Lombardy region

🇮🇹

Phase 3

All branches nationwide

Step 1: Create Rule-Based Segments

Create segments that match users by their branch or region attribute:

Segment: “Milan Pilot Branches”

Type: Rule-Based • Condition: branch_id in MI-001, MI-002, MI-003

Segment: “Lombardy Region”

Type: Rule-Based • Condition: region equals lombardy

Step 2: Create the Flag with Phased Rules

Create a flag called new-account-opening with global rollout at 0%. Add targeting rules in priority order:

1

User in segment “Milan Pilot Branches”

Rollout: 100% • Enabled from day 1

2

User in segment “Lombardy Region”

Rollout: 100% • Enable after Phase 1 validation

3

Global rollout

Start at 0%, increase to 25% → 50% → 100% for nationwide rollout

Step 3: Integrate in Your App

The key is passing branch and region as user attributes so Rollgate can evaluate the targeting rules:

React - Branch-Aware Provider
import { RollgateProvider, useFlag } from '@rollgate/sdk-react';

function App() {
  const user = useAuthenticatedUser();
  const branch = useBranchContext();

  return (
    <RollgateProvider
      apiKey="YOUR_CLIENT_KEY"
      user={{
        id: user.id,
        attributes: {
          branch_id: branch.id,     // e.g. "MI-001"
          region: branch.region,    // e.g. "lombardy"
          role: user.role,          // e.g. "teller", "manager"
        },
      }}
    >
      <BankingApp />
    </RollgateProvider>
  );
}

function AccountOpeningPage() {
  const newFlow = useFlag('new-account-opening', false);

  if (newFlow) {
    return <NewAccountOpening />;
  }

  return <LegacyAccountOpening />;
}
Node.js - Server-Side with Branch Context
import { RollgateClient } from '@rollgate/sdk-node';

const rollgate = new RollgateClient({
  apiKey: process.env.ROLLGATE_SERVER_KEY,
  enableStreaming: true,
});

await rollgate.init();

app.post('/api/accounts/open', async (req, res) => {
  const user = await getAuthenticatedUser(req);
  const branch = await getBranchInfo(user.branchId);

  const useNewFlow = rollgate.isEnabled('new-account-opening', false, {
    userId: user.id,
    attributes: {
      branch_id: branch.id,      // "MI-001"
      region: branch.region,     // "lombardy"
      role: user.role,           // "teller"
    },
  });

  if (useNewFlow) {
    return handleNewAccountFlow(req, res, user);
  }

  return handleLegacyAccountFlow(req, res, user);
});
Go - Backend Middleware
package main

import (
    "net/http"
    rollgate "github.com/rollgate/sdk-go"
)

var client *rollgate.Client

func init() {
    client, _ = rollgate.NewClient(rollgate.Config{
        APIKey:          os.Getenv("ROLLGATE_SERVER_KEY"),
        EnableStreaming:  true,
    })
}

func accountOpeningHandler(w http.ResponseWriter, r *http.Request) {
    user := getUserFromContext(r.Context())
    branch := getBranchInfo(user.BranchID)

    useNewFlow := client.IsEnabled("new-account-opening", false,
        rollgate.WithUser(user.ID),
        rollgate.WithAttributes(map[string]interface{}{
            "branch_id": branch.ID,     // "MI-001"
            "region":    branch.Region,  // "lombardy"
            "role":      user.Role,      // "teller"
        }),
    )

    if useNewFlow {
        handleNewAccountFlow(w, r, user)
        return
    }

    handleLegacyAccountFlow(w, r, user)
}

Rollout Timeline

Week 1-2

Phase 1: Pilot

Enable rule 1 (Milan Pilot Branches). Monitor error rates, user feedback, and completion rates at MI-001, MI-002, MI-003.

Week 3-4

Phase 2: Regional

Enable rule 2 (Lombardy Region). All ~40 branches in the region get the new flow. If issues arise, disable the rule instantly for a 1-click rollback.

Week 5-8

Phase 3: Nationwide

Increase global rollout progressively: 25% → 50% → 75% → 100%. Each step is a simple slider change in the dashboard. No code deploy needed.

Safety Tips for Regulated Industries

  • Audit trail: Every flag change is logged with who changed it, when, and what the previous value was
  • Instant rollback: If something goes wrong, disable the rule or set global rollout to 0% in one click
  • No code deploy:Rollout changes happen from the dashboard, not from a code release — reducing deployment risk
  • Gradual rollout: The percentage-based rollout is deterministic per user (based on user ID hash), so the same user always gets the same experience