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. Usepopulate to fetch the full related data.
Basic Population
- Populate All
- Selective Population
- Deep Population
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 withconnect, 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
Full Advanced Relations Example
Full Advanced Relations Example
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:Performance Tips
Only populate what you need
Only populate what you need
Avoid deep nesting
Avoid deep nesting
Use pagination for to-many relations
Use pagination for to-many relations
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