Skip to main content
Strapi relations connect content types together. strapi2front generates fully-typed interfaces and helpers for working with all relation types.

Relation Types

Strapi supports four relation types, all handled automatically by strapi2front:

One-to-One

Single item relates to single item (e.g., Article → Author)

One-to-Many

Single item relates to multiple items (e.g., Author → Articles)

Many-to-One

Multiple items relate to single item (e.g., Articles → Category)

Many-to-Many

Multiple items relate to multiple items (e.g., Articles ↔ Tags)

Generated Types for Relations

To-One Relations

For one-to-one and many-to-one relations, the generated type is nullable:
article.ts

To-Many Relations

For one-to-many and many-to-many relations, the generated type is an array:
article.ts

Populating Relations

By default, Strapi returns only relation IDs. Use populate to fetch the full related data.

Basic Population

Using populate: '*' can be slow and return large responses. Use selective population in production.

Population in Queries

Creating Relations

When creating or updating content, use documentId (v5) or id (v4) to link relations.

Simple Relation Format

Advanced Relation Format (Strapi v5)

Strapi v5 supports advanced relation operations with connect, disconnect, and set:
1

connect

Add relations while preserving existing ones
2

disconnect

Remove specific relations without affecting others
3

set

Replace ALL relations with a new set

Querying by Relations

Filter content by related items:

Real-World Examples

Blog with Author and Categories

pages/blog/[slug].astro

Filter Articles by Category

pages/category/[slug].astro

Author Profile with Articles

pages/author/[slug].astro

Bidirectional Relations

When relations are bidirectional (defined on both sides), Strapi keeps them in sync:
Bidirectional relations are updated automatically by Strapi. You only need to update one side.

Performance Tips

If a content type has hundreds of relations, consider paginating:

Next Steps

Media

Work with images and file uploads

Services

Learn more about service methods

Types

Understand generated TypeScript types

Schemas

Validate relation data with Zod