Groups

Give a flag to specific people first: your team, beta customers, or everyone at a company. Lists stay on your servers and never reach a browser.

A group is a named set of people. Target a flag at a group and those people get it first, whatever the percentage says. It’s how you turn a feature on for your own team in production, or for the customers who agreed to try it early, before anyone else sees it.

Your code doesn’t change: getFlag, useFlag and isEnabled return true for people in a targeted group. You pass email next to userId so Flaggish can tell who they are.

Two kinds of group

TypeIn the dashboardWho is in it
ListSpecific peopleThe user IDs and emails you list, up to 1,000. A person matches by user ID (exactly) or by email (any case, spaces ignored).
Company domainsEveryone at a companyAnyone whose email is at one of up to 20 domains. acme.com matches bob@acme.com but not bob@mail.acme.com: subdomains aren’t included.

Group names are up to 50 characters and must be unique in a project. A person with neither a user ID nor an email isn’t in any group.

Create a group

Open Groups in the project’s sidebar and click New group. Pick Specific people or Everyone at a company, then:

  • Specific people: paste user IDs and emails, one per line or separated by commas. A counter shows how many of the 1,000 you’ve used. Emails are saved in lower case, and blanks and repeats are dropped.
  • Everyone at a company: add one or more domains, such as acme.com. A leading @ is removed, and each one must be a valid domain name.

Admins can create, edit and delete groups. Anyone in the project can see the list of groups, but only Admins and the owner see who is in a list: everyone else sees how many people it has.

Groups belong to the project, so both environments share them. Who gets a flag is set per flag, per environment, like the switch.

Give a flag to groups

On the Feature flags page, open the ⋯ menu on a flag and click Who gets it (once a flag has a rollout or groups, click its chip instead). The panel is titled Who gets flag in Environment? and has three modes:

ModeWho gets it
EveryoneEveryone, as a normal flag that’s on.
A percentageA share of people, picked with a stable answer for each person.
GroupsThe people in the groups you pick, then a share of everyone else.

With Groups, pick one or more groups, then choose And everyone else: Nobody, 5%, 10%, 25%, 50% or Custom. Nobody is “only them”: the flag is on for the groups and off for the rest. A percentage gives the feature to those groups first, then to that share of everyone else.

See percentage rollouts for how a percentage works. Admins and Togglers can change who gets a flag. Click Save to apply it. While a flag is in a running schedule, you can’t change who gets it. A flag still needs to be switched on: a flag that’s switched off is off for everyone, groups included.

How a flag is decided

For each person, in this order:

  1. If the flag is switched off, it’s off.
  2. If the person is in any targeted group, it’s on.
  3. Otherwise the percentage applies, as in percentage rollouts.

The percentage always uses the person’s userId, or their anonymous ID if they have none. It never uses their email, so adding groups doesn’t move anyone between buckets.

Set up your app

Domain groups work anywhere you pass email. List groups need one more step, because the people in a list must never reach a browser.

Groups need @flaggish/sdk 2.0.0-beta.3 or later; earlier 2.x betas treat everyone as not in a group; v1 SDKs never get a groups-targeted flag.

Add your secret key

Copy the secret key from Settings › API keys in the dashboard and set it on your server:

.env
FLAGGISH_SECRET_KEY=your-secret-key

The secret key is for servers only. Never give it a NEXT_PUBLIC_ name, never commit it, and never put it in browser code. The SDK reads FLAGGISH_SECRET_KEY and nothing else, so a NEXT_PUBLIC_ variable is ignored.

With the key, your server downloads the people in the lists your flags use, then checks them in memory like any other flag. The list is cached for 30 seconds, like your flags, and if a refresh fails the last good copy is used. Only Admins can see the secret key in the dashboard.

Next.js

Pass the signed-in user’s userId and email to the provider, and to getFlag and getFlags in server code:

app/layout.tsx
import { currentUser } from '@clerk/nextjs/server';
import { FlaggishServerProvider } from '@flaggish/sdk/next';

async function Flags({ children }: { children: React.ReactNode }) {
  const user = await currentUser(); // from your auth library; null when signed out
  return (
    <FlaggishServerProvider userId={user?.id} email={user?.primaryEmailAddress?.emailAddress}>
      {children}
    </FlaggishServerProvider>
  );
}
app/dashboard/page.tsx
import { currentUser } from '@clerk/nextjs/server';
import { getFlag } from '@flaggish/sdk/next';

export default async function Page() {
  const user = await currentUser(); // from your auth library
  const userId = user?.id;
  const email = user?.primaryEmailAddress?.emailAddress;
  const showDialog = await getFlag('dialog', { userId, email });
  return showDialog ? <Dialog /> : null;
}

FlaggishServerProvider checks the lists on your server and sends the browser only which groups this person is in, never who else is in them. Client components then read the right value on first paint. See Next.js.

Node

flags.ts
import { createFlaggish } from '@flaggish/sdk';

// Reads FLAGGISH_SECRET_KEY, or pass secretKey explicitly.
export const flaggish = createFlaggish();

const on = await flaggish.isEnabled('dialog', { userId: 'user_123', email: 'bob@acme.com' });

See Node.

React in the browser

A plain React app has no server, so it can’t hold a secret key. It can check company domains: pass email to FlaggishProvider.

App.tsx
import { FlaggishProvider } from '@flaggish/sdk/react';
import { useUser } from './auth'; // your auth hook
import { Page } from './Page';

export const App = () => {
  const user = useUser(); // from your auth library; null when signed out
  return (
    <FlaggishProvider clientKey="your-client-key" userId={user?.id ?? null} email={user?.email ?? null}>
      <Page />
    </FlaggishProvider>
  );
};

For lists, work out the person’s groups on a server and pass the result as groupIds, or use Next.js, where FlaggishServerProvider does it for you. See React.

Without a secret key

If a flag targets a list and your server has no secret key, the SDK treats everyone as not in the list, so they fall to the percentage under And everyone else. It logs one warning, once per process:

Console
[flaggish] A flag targets a list group but no secret key is set (FLAGGISH_SECRET_KEY). Treating users as not in the group.

The Who gets it panel shows a hint when a list group is selected and no server has used your secret key yet: “Lists need your secret key on the server. We haven’t seen it from this project yet.”

What stays private

  • Lists never reach a browser. The public config only says which list a flag targets, never who is in it. Members are sent only to servers that present your secret key, and a browser only ever learns which groups the current person is in.
  • Domains are not secret. They’re part of the public config, because a browser needs them to check an email. They’re company domains, not people.
  • Emails stay in your app. The SDK never sends user IDs, anonymous IDs or emails to Flaggish; it checks them inside your app. See What Flaggish collects.
  • Logs never list who is in a group. Creating, editing and deleting a group, and changing who gets a flag, are logged with group names and counts, never members.

Plans and limits

Flagpole (free)Full Mast
Groups per project1Unlimited
People per list1,0001,000
Domains per group2020
Group name50 characters50 characters

If a Flagpole project has more than one group, for example after leaving Full Mast, flags keep working for everyone already targeted. Creating or editing groups, and adding a group to a flag, are blocked until you’re back to one group or upgrade. Removing groups from flags and deleting groups still work.

Groups and the rollout limit

Flagpole allows 5 rollouts. A flag in Groups mode uses one of the 5 only when And everyone else is above 0%. A flag that’s “only them” (Nobody) never does, so you can give as many flags as you like to your team on Flagpole, within your one group. Choosing a percentage above 0% uses a slot, and going back to Nobody frees it.

Delete a group

Open the group’s options menu and click Delete group. The group is taken off every flag that uses it. The dialog lists any flags that will be switched off, and any in a running schedule:

  • A flag that still has other groups, or a percentage above 0%, keeps its settings.
  • A flag left with no groups and “only them” is switched off, so it never quietly changes who gets it. The dialog lists these, for example “new-checkout in Production will be switched off”, and each one is logged.
  • The group is still removed from a flag in a running schedule, but the flag isn’t switched off, because the schedule controls it.
Was this page helpful?

Request early access

Become a beta user, or stay up to date with the project.