Skip to main content
The 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.js
  • strapi.config.mjs
  • strapi.config.cjs
Use TypeScript for autocomplete and validation while editing your config.

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.
Never hardcode tokens in your config. Always use environment variables.
The token is read in this order:
  1. token field in config
  2. STRAPI_SYNC_TOKEN environment variable
  3. STRAPI_TOKEN environment 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:
'esm' | 'commonjs'
Module system for JSDoc output. Auto-detected from package.json if not specified.
Only relevant when outputFormat: "jsdoc". TypeScript always uses ESM syntax.
Auto-detection rules:
  • Checks package.json for "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.
Actions are only generated when outputFormat: "typescript". They are skipped for JSDoc output.
boolean
Generate Zod validation schemas for form handling.
Default value:
  • true when outputFormat: "typescript"
  • false when outputFormat: "jsdoc"
Zod schemas work best with TypeScript. For JSDoc projects, schemas are disabled by default.
boolean
default:false
Generate file upload helpers for browser and server.
See Features > Upload for setup details.

Schema Options

Configure how Zod schemas are generated.
boolean
default:false
Use advanced relation format with connect/disconnect/set operations.
Generates simple array format:
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:
Security Best Practices:
  • Never hardcode tokens in your config file
  • Never commit .env to version control (add to .gitignore)
  • Never deploy STRAPI_SYNC_TOKEN to production
  • Use separate tokens with minimal permissions for each environment

Type Safety

The config uses Zod validation. Invalid configurations are caught immediately:
Use defineConfig() to get autocomplete and validation in your editor.

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