Ir al contenido

Config Options

Esta página aún no está disponible en tu idioma.

Complete reference for all configuration options in strapi.config.ts.

import { defineConfig } from "strapi2front";
export default defineConfig({
// options here
});

Type: string Required: Yes

The base URL of your Strapi server.

url: "http://localhost:1337"
// or with environment variable
url: process.env.STRAPI_URL || "http://localhost:1337"

Type: string | undefined Required: No (but needed for protected schemas)

Your Strapi API token for authentication.

token: process.env.STRAPI_TOKEN

Type: string Default: "/api"

The API prefix configured in your Strapi instance.

apiPrefix: "/api" // default
// or custom prefix
apiPrefix: "/v1"

Type: "v4" | "v5" Default: Auto-detected

Explicitly set the Strapi version. Usually auto-detected.

strapiVersion: "v5"

Type: "typescript" | "jsdoc" Default: "typescript"

Choose output format:

  • typescript: Generates .ts files with type annotations
  • jsdoc: Generates .js files with JSDoc comments
outputFormat: "typescript" // default
// or for JavaScript projects
outputFormat: "jsdoc"

Type: "esm" | "commonjs" Default: Auto-detected

Module system for JSDoc output. Auto-detected from package.json.

moduleType: "esm"

Type: object

Configure where files are generated.

output: {
path: "src/strapi",
}

Type: string Default: "src/strapi"

Base output directory for generated files.


Type: object

Enable or disable specific generators.

features: {
types: true,
services: true,
actions: true,
schemas: true,
upload: false,
}

Type: boolean Default: true

Generate TypeScript interfaces for content types.

Type: boolean Default: true

Generate API service functions with CRUD operations.

Type: boolean Default: false

Generate Astro actions. Only works with outputFormat: "typescript".

Type: boolean Default: false

Generate Zod validation schemas.

Type: boolean Default: false

Generate upload helpers for file uploads to Strapi:

  • shared/upload-client.ts - Browser upload client (public token)
  • shared/upload-action.ts - Astro Action for secure server-side uploads

Requires additional environment variables:

Terminal window
PUBLIC_STRAPI_URL=http://localhost:1337
PUBLIC_STRAPI_UPLOAD_TOKEN=your-restricted-token

Type: object

Configure Zod schema generation.

schemaOptions: {
advancedRelations: true,
}

Type: boolean Default: false

Enable advanced Strapi v5 relation format with connect, disconnect, and set operations.

When false:

// Relations as simple IDs
author: z.string().optional()
categories: z.array(z.string()).optional()

When true:

// Relations with connect/disconnect/set
categories: z.union([
z.array(z.string()),
z.object({
connect: z.array(...).optional(),
disconnect: z.array(...).optional(),
set: z.array(...).optional(),
}),
]).optional()

import { defineConfig } from "strapi2front";
export default defineConfig({
// Connection
url: process.env.STRAPI_URL || "http://localhost:1337",
token: process.env.STRAPI_TOKEN,
apiPrefix: "/api",
strapiVersion: "v5",
// Output format
outputFormat: "typescript",
// File organization
output: {
path: "src/strapi",
},
// Features
features: {
types: true,
services: true,
actions: true,
schemas: true,
},
// Schema options
schemaOptions: {
advancedRelations: true,
},
});

The defineConfig function provides full TypeScript support with autocompletion and validation:

import { defineConfig } from "strapi2front";
import type { Config } from "strapi2front";
// Full type checking and autocompletion
export default defineConfig({
url: "http://localhost:1337",
// ... other options
});

Use environment variables for different environments:

import { defineConfig } from "strapi2front";
const isDev = process.env.NODE_ENV === "development";
export default defineConfig({
url: isDev
? "http://localhost:1337"
: process.env.STRAPI_URL,
token: process.env.STRAPI_TOKEN,
// ... other options
});