Skip to main content

Overview

A variant flag serves one of a fixed set of string values. In this guide you add search-variant with the variants control, semantic, and hybrid, push it, and switch on the served value in code.

Steps

1

Define the flag

For Go, add definitions to Config in shipd.config.go, then run shipd push. See Define flags in code for the complete file.default must be one of variants. TypeScript checks this at compile time; Go’s ShipdConfig validates it when exporting. In TypeScript, keep as const to preserve literal variants.
2

Push it

3

Evaluate it

In React:
src/components/search.tsx
See getVariant.
4

Choose who gets which variant

On the flag page in the dashboard, set Fallthrough to a variant, or add rules whose Serve is a variant. Click Save environment.
To split users randomly across variants, see Run an A/B test.

Create it without a config file

--variants is required with --type variant. See CLI reference.