Sync Commands
Sync commands bridge the Strapi CMS and the React app codebase. They pull content from Strapi into TypeScript files (sync) or push local changes back to Strapi (reverse-sync).
sync:questionnaire
Section titled “sync:questionnaire”Fetches questionnaire data from Strapi and generates TypeScript files with i18n wrapping.
yarn sync:questionnaire [-q slug] [-t type] [-d dir] [-s source]Options
Section titled “Options”| Flag | Long form | Type | Default | Description |
|---|---|---|---|---|
-q |
--questionnaireSlug |
string | — | Sync only one questionnaire by its slug |
-t |
--questionnaireType |
enum | all |
Filter by type: signup, claim, adjustPolicy, cancelPolicy, all |
-d |
--dir |
string | src/syncedData/questionnaires |
Output directory for generated files |
-s |
--source |
enum | — | Source environment: prod, staging, dev |
Output
Section titled “Output”Generates TypeScript files in the output directory. Each file:
- Exports a typed questionnaire definition object
- Wraps all user-facing strings with i18n translation functions using the questionnaire’s
translationKey - Includes all questions, rules, screens, validations, and metadata
Examples
Section titled “Examples”Sync all questionnaires from staging:
yarn sync:questionnaire -s stagingSync a single questionnaire:
yarn sync:questionnaire -q household -s stagingSync only claim questionnaires:
yarn sync:questionnaire -t claim -s stagingsync:questionnaire:dev
Section titled “sync:questionnaire:dev”Same as sync:questionnaire but uses .env.development for environment configuration.
yarn sync:questionnaire:dev [-q slug] [-t type] [-d dir]Accepts the same options as sync:questionnaire except -s (source is always the dev environment).
reverse-sync:questionnaire
Section titled “reverse-sync:questionnaire”Reads a local TypeScript questionnaire file and pushes changes back to Strapi.
yarn reverse-sync:questionnaire -q <slug> [-t target] [--dependent] [--main-only] [--dry-run] [--force]Options
Section titled “Options”| Flag | Long form | Type | Default | Required | Description |
|---|---|---|---|---|---|
-q |
--slug |
string | — | Yes | Questionnaire slug to reverse-sync |
-t |
--target |
enum | staging |
No | Target environment: prod, staging, dev |
| — | --dependent |
boolean | false |
No | Only sync the dependent variant |
| — | --main-only |
boolean | false |
No | Only sync the main (non-dependent) variant |
| — | --dry-run |
boolean | false |
No | Show the diff without pushing changes to Strapi |
| — | --force |
boolean | false |
No | Skip the confirmation prompt |
Behavior
Section titled “Behavior”- Reads the local TypeScript questionnaire file
- Compares it against the current Strapi content
- Shows a diff of changes
- Prompts for confirmation (unless
--forceis used) - Pushes the changes to the target Strapi environment
Examples
Section titled “Examples”Dry-run to see what would change:
yarn reverse-sync:questionnaire -q household --dry-runPush to staging (default target):
yarn reverse-sync:questionnaire -q householdPush to production with confirmation skip:
yarn reverse-sync:questionnaire -q household -t prod --forceSync only the dependent variant:
yarn reverse-sync:questionnaire -q household --dependentreverse-sync:questionnaire:promote
Section titled “reverse-sync:questionnaire:promote”Promotes a draft questionnaire to published status in Strapi.
yarn reverse-sync:questionnaire:promote -q <slug> [-t target]Options
Section titled “Options”| Flag | Long form | Type | Default | Required | Description |
|---|---|---|---|---|---|
-q |
--slug |
string | — | Yes | Questionnaire slug to promote |
-t |
--target |
enum | — | No | Target environment: prod, staging, dev |
Behavior
Section titled “Behavior”Changes the questionnaire’s status from draft to published in the target Strapi environment. This makes the questionnaire available via the Strapi API and, consequently, in the preview system.
Example
Section titled “Example”yarn reverse-sync:questionnaire:promote -q household -t stagingsync:verticals
Section titled “sync:verticals”Fetches all vertical definitions from staging Strapi and generates TypeScript mapping files.
yarn sync:verticalsOptions
Section titled “Options”No options. Always syncs from the staging environment.
Output
Section titled “Output”Generates the following files:
src/models/insurances/types/mapping/index.ts
Section titled “src/models/insurances/types/mapping/index.ts”Contains:
| Export | Description |
|---|---|
InsuranceTypes enum |
All insurance type identifiers (e.g., HOUSEHOLD, PUBLIC_HEALTH) |
| Title lookups | Maps insurance types to display titles |
| Excerpt lookups | Maps insurance types to short descriptions |
| Description lookups | Maps insurance types to full descriptions |
| Color mappings | Maps insurance types to hex color codes |
| Image mappings | Maps insurance types to icon/logo URLs |
src/syncedData/policyModals/*.ts
Section titled “src/syncedData/policyModals/*.ts”One file per vertical containing:
- Policy modal section content (body text, lists)
- Policy modal button configuration (text, href, variant)
Example
Section titled “Example”yarn sync:verticalsTypical Workflows
Section titled “Typical Workflows”Making a questionnaire change via CMS
Section titled “Making a questionnaire change via CMS”- Edit the questionnaire in Strapi
- Sync it locally:
yarn sync:questionnaire -q <slug> -s staging - Review the generated TypeScript diff
- Create a pull request with the changes
Making a questionnaire change via code
Section titled “Making a questionnaire change via code”- Edit the local TypeScript questionnaire file
- Dry-run to verify:
yarn reverse-sync:questionnaire -q <slug> --dry-run - Push to staging:
yarn reverse-sync:questionnaire -q <slug> - Preview in the staging app
- Promote when ready:
yarn reverse-sync:questionnaire:promote -q <slug> -t staging
Adding a new vertical
Section titled “Adding a new vertical”- Create the vertical in Strapi
- Sync all verticals:
yarn sync:verticals - Review the generated mapping files
- Create a pull request with the changes
See also
Section titled “See also”- Sync a Questionnaire – task-focused guide for forward sync
- Reverse-Sync a Questionnaire – task-focused guide for reverse sync
- Strapi Transform Pipeline – how data is transformed during sync operations