Skip to main content
Version: next

Content Composition

Since version 3.11

References

For more detailed information, check out:

Introduction

Content Composition is a powerful feature that allows you to create reusable building blocks for your content. It helps you:

  • Build modular and maintainable content structures
  • Implement type-safe GraphQL fragments
  • Create flexible page layouts using composable components

This guide will walk you through implementing content composition in your Front-Commerce application.

Prerequisites

Before starting, make sure you:

Tutorial

Advanced Usage

Overriding Existing Compositions

You can override existing compositions by registering a new composition with the same name:

composition.register("Wysiwyg", [
{
name: "DefaultWysiwyg",
client: {
component: new URL("./components/DefaultWysiwyg.tsx", import.meta.url),
fragment: /* GraphQL */ `
fragment DefaultWysiwygFragment on DefaultWysiwyg {
childNodes
data {
dataId
}
customField // Add new fields
}
`,
},
},
]);
tip

When overriding compositions, the last registered extension takes precedence, but all compositions are merged together.