Skip to main content
strapi2front generates different types of code based on your Strapi schema. Enable or disable features to match your project needs.

Feature Configuration

strapi.config.ts
All features work together. For example, services use types, and actions use both services and schemas.

Types

Generates TypeScript interfaces for all content types, components, and system types.

Generated Files

  • collections/{name}/types.ts - Collection type interfaces
  • singles/{name}/types.ts - Single type interfaces
  • components/{name}.ts - Component interfaces
  • shared/utils.ts - System types (media, pagination, base entities)

What’s Included

collections/article/types.ts
singles/homepage/types.ts
components/hero.ts
shared/utils.ts

Version Differences

Services use documentId: string for all operations.

Services

Generates fully-typed API service functions for fetching and mutating data.

Generated Files

  • collections/{name}/service.ts - Collection CRUD operations
  • singles/{name}/service.ts - Single type operations
  • shared/client.ts - Strapi client wrapper

Collection Services

Every collection gets a full CRUD service:
collections/article/service.ts

Single Type Services

singles/homepage/service.ts

Usage Examples

Client Options (Beta)

Pass custom authentication or base URL per request:

Actions

Generates Astro Actions for type-safe server-side API operations.
Actions are only generated for TypeScript projects (outputFormat: "typescript"). They are automatically skipped when using JSDoc output.

Generated Files

  • collections/{name}/actions.ts - Astro action definitions

Usage with Astro

For more framework integrations (Next.js, Nuxt, etc.), see the Astro, Next.js, and Nuxt guides.

Schemas

Generates Zod validation schemas for form handling and data validation.
Default behavior:
  • true when outputFormat: "typescript"
  • false when outputFormat: "jsdoc"

Generated Files

  • collections/{name}/schemas.ts - Create/update schemas
  • singles/{name}/schemas.ts - Update schemas
  • components/{name}.ts - Component schemas (appended to types file)

Schema Types

Each content type gets two schemas:
collections/article/schemas.ts

Advanced Relations

Enable the full Strapi v5 relation API:
strapi.config.ts

Form Integration

Upload

Generates file upload helpers for uploading media to Strapi.

Generated Files

  • shared/upload-client.ts - Browser-side upload (public token)
  • shared/upload-action.ts - Server-side Astro Action (requires actions: true)

Two Upload Strategies

Security Setup

For public upload client:
  1. Create a dedicated API token in Strapi: Settings > API Tokens
  2. Set permissions to Upload > upload ONLY
  3. Never grant delete or update permissions
  4. Token is visible in browser - keep permissions minimal

Usage with Relations

After uploading, use the returned id to link to content:

CLI Overrides

Generate only specific features using CLI flags:
CLI flags override config settings. Use for one-off regeneration without editing config.
strapi.config.ts

Next Steps

Output Structure

See where files are generated

Using Services

Learn how to use generated services