Skip to content

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.

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

The sync script generates a separate file for each variant. The file name is derived from the questionnaire slug + variant slug:

  • Variant slug default produces {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.ts
  • public-health-barmer.ts
  • public-health-tk.ts
  • public-health-dak.ts

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 insurance

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' },