Set Up Variants
Variants let you generate multiple versions of the same questionnaire — one per provider, plan, or condition — from a single Strapi entry. Each variant produces its own synced file with variant-specific data injected at build time.
Prerequisites
Section titled “Prerequisites”- A published questionnaire in Strapi
- Familiarity with the sync process (see Request a Content Sync)
1. Add variants to questionnaire metadata
Section titled “1. Add variants to questionnaire metadata”In Strapi, open your questionnaire and scroll to the Metadata section. Add entries to the variants repeatable component. Each variant has three fields:
| Field | Format | Description |
|---|---|---|
slug |
^[a-z]+(-[a-z]+)*$ |
URL-safe identifier. Use default for the base variant. |
name |
free text | Human-readable name (e.g., AOK, BARMER). |
value |
^[A-Za-z0-9]+(_[A-Za-z0-9]+)*$ |
Machine-readable value passed to the backend. |
Example — public health insurance with four provider variants:
| slug | name | value |
|---|---|---|
aok |
AOK |
aok |
barmer |
BARMER |
barmer |
tk |
TK |
tk |
dak |
DAK |
dak |
2. Understand file generation
Section titled “2. Understand file generation”The sync script generates a separate file for each variant. The file name is derived from the questionnaire slug + variant slug:
- Variant slug
defaultproduces{questionnaire-slug}.ts(no suffix) - Any other slug produces
{questionnaire-slug}-{variant-slug}.ts
For the public health example above, syncing produces:
public-health-aok.tspublic-health-barmer.tspublic-health-tk.tspublic-health-dak.ts
3. Use variant data in interpolations
Section titled “3. Use variant data in interpolations”Each synced variant file receives a variant object with slug, name, and value. You can reference these in question text and descriptions:
{{answers.variant}}— the variant slug (e.g.,aok){{answers.variantData.name}}— the variant display name (e.g.,AOK){{answers.variantData.value}}— the variant value (e.g.,aok)
Example question text:
Sign up for {{answers.variantData.name}} public health insurance4. Sync and verify
Section titled “4. Sync and verify”Run the questionnaire sync. Confirm that one file per variant appears in src/syncedData/questionnaires/. Each file’s header will contain the variant object:
variant: { slug: 'aok', name: 'AOK', value: 'aok' },See also
Section titled “See also”- Questionnaire Metadata — full field reference for the metadata schema
- Configure Interpolations — how to use dynamic values in question text
- Engineering: Run Sync — running the sync process
- Strapi Transform Pipeline — how sync transforms Strapi data into TypeScript files