Skip to main content
strapi2front generates complete TypeScript type definitions from your Strapi content types, providing full type safety for your frontend application.

What Gets Generated

When you run npx strapi2front sync, the generator creates:

Collection Types

TypeScript interfaces with full type safety for all your collection types

Single Types

Interfaces for single types like homepage, settings, etc.

Components

Reusable component interfaces referenced by your content types

Utility Types

Helper types for media, pagination, responses, and more

Generated File Structure

Collection Type Example

For a Blog Article collection type in Strapi, the generator creates:

Attribute Type Mappings

strapi2front maps Strapi field types to TypeScript types:

Utility Types

The generator also creates utility types in utils.ts:
Base interface that all content types extend. Contains system fields.
Type definition for media files (images, videos, etc.)
Rich text blocks for Strapi v5’s new blocks editor.
For full type support and rendering, install @strapi/blocks-react-renderer then re-run npx strapi2front sync.
Wrapper types for API responses with metadata.

Using Generated Types

Import Types in Your Components

pages/blog/[slug].astro

Type-Safe Data Fetching

utils/blog.ts

Working with Relations

components/ArticleCard.tsx

Field Validation Attributes

The generator includes validation constraints from your Strapi schema as JSDoc comments:

Dynamic Zones

For dynamic zones (flexible content areas), the generator creates discriminated unions:
You can use TypeScript’s type narrowing:
Types are automatically regenerated when you run npx strapi2front sync. Make sure to sync after changing your Strapi schema.

Next Steps

Services

Learn how to use generated service functions for data fetching

Schemas

Validate form data with generated Zod schemas

Relations

Working with related content types

Media

Handle images and file uploads