strapi.config.ts file is your central configuration for strapi2front. It controls how types, services, schemas, and actions are generated from your Strapi schema.
Quick Start
strapi.config.ts
File Location
Place your config file in your project root. strapi2front looks for these files in order:strapi.config.ts(recommended)strapi.config.jsstrapi.config.mjsstrapi.config.cjs
Connection Options
Configure how strapi2front connects to your Strapi instance.string
required
Base URL of your Strapi server (without
/api suffix)string
API token for authentication. Required for fetching schema.The token is read in this order:
tokenfield in configSTRAPI_SYNC_TOKENenvironment variableSTRAPI_TOKENenvironment variable
string
default:"/api"
API prefix used by Strapi. Customize if you’ve changed the default in Strapi.
'v4' | 'v5'
default:"v5"
Target Strapi version. Auto-detected during sync if not specified.
strapi2front auto-detects the version from your Strapi instance and warns you if there’s a mismatch.
Output Options
Control where and how files are generated.string
default:"src/strapi"
Directory where generated files will be written.
'typescript' | 'jsdoc'
default:"typescript"
Choose between TypeScript or JavaScript with JSDoc annotations.Generates:
- TypeScript
- JSDoc
'esm' | 'commonjs'
Module system for JSDoc output. Auto-detected from package.json if not specified.Auto-detection rules:
Only relevant when
outputFormat: "jsdoc". TypeScript always uses ESM syntax.- Checks
package.jsonfor"type": "module" - Defaults to
"commonjs"if not found
Feature Toggles
Enable or disable specific code generators. See Features for detailed documentation.boolean
default:true
Generate TypeScript interfaces for all content types.
boolean
default:true
Generate API service functions with full CRUD operations.
boolean
default:true
Generate Astro Actions for server-side API calls.
boolean
Generate Zod validation schemas for form handling.Default value:
truewhenoutputFormat: "typescript"falsewhenoutputFormat: "jsdoc"
Zod schemas work best with TypeScript. For JSDoc projects, schemas are disabled by default.
boolean
default:false
Schema Options
Configure how Zod schemas are generated.boolean
default:false
Use advanced relation format with Generates simple array format:
connect/disconnect/set operations.- Simple (default)
- Advanced
See Strapi Relations API for complete documentation.
boolean
default:false
Include draft content types in generation.
Reserved for future use. Currently has no effect.
boolean
default:false
Generate strict types with no optional fields.
Reserved for future use. Currently has no effect.
Complete Example
strapi.config.ts
Environment Variables
Recommended.env setup:
Type Safety
The config uses Zod validation. Invalid configurations are caught immediately:Config Schema
The configuration is validated using this Zod schema:packages/core/src/config/schema.ts
Next Steps
Features
Learn about each feature in detail
Output Structure
Understand the generated file structure