Config File
The strapi.config.ts file is the central configuration for strapi2front. It controls how types, services, and schemas are generated.
Basic Configuration
Section titled “Basic Configuration”import { defineConfig } from "strapi2front";
export default defineConfig({ // Strapi server URL url: process.env.STRAPI_URL || "http://localhost:1337",
// API token for authentication token: process.env.STRAPI_TOKEN,
// Output configuration output: { path: "src/strapi", },
// Features to generate features: { types: true, services: true, schemas: true, },});Configuration Options
Section titled “Configuration Options”The base URL of your Strapi server.
url: "http://localhost:1337"Your Strapi API token. Required for fetching the schema.
token: process.env.STRAPI_TOKENapiPrefix
Section titled “apiPrefix”The API prefix used by Strapi. Defaults to /api.
apiPrefix: "/api" // defaultstrapiVersion
Section titled “strapiVersion”Explicitly set the Strapi version. Auto-detected if not specified.
strapiVersion: "v5" // or "v4"outputFormat
Section titled “outputFormat”Choose between TypeScript or JavaScript with JSDoc.
outputFormat: "typescript" // default, generates .ts files// oroutputFormat: "jsdoc" // generates .js files with JSDoc commentsoutput
Section titled “output”Configure where files are generated.
output: { // Base output directory path: "src/strapi",}features
Section titled “features”Enable or disable specific generators.
features: { types: true, // TypeScript interfaces services: true, // API service functions actions: true, // Astro actions (TypeScript only) schemas: true, // Zod validation schemas}schemaOptions
Section titled “schemaOptions”Configure Zod schema generation.
schemaOptions: { // Enable advanced relation format with connect/disconnect/set advancedRelations: true,}Full Example
Section titled “Full Example”import { defineConfig } from "strapi2front";
export default defineConfig({ url: process.env.STRAPI_URL || "http://localhost:1337", token: process.env.STRAPI_TOKEN, apiPrefix: "/api", strapiVersion: "v5", outputFormat: "typescript",
output: { path: "src/strapi", structure: "by-feature", },
features: { types: true, services: true, actions: true, schemas: true, },
schemaOptions: { advancedRelations: true, },});Environment Variables
Section titled “Environment Variables”strapi2front uses two separate tokens for different purposes:
STRAPI_URL=http://localhost:1337
# Sync token: Used by strapi2front to sync schema (development only)# Permissions: content-type-builder (getContentTypes, getComponents), i18n (listLocales)STRAPI_SYNC_TOKEN=your-sync-api-token-here
# Frontend token: Used by your app to fetch content (production)# Configure with only the permissions your app needsSTRAPI_TOKEN=your-frontend-api-token-here