Note: Studio is currently part of an Early Access Program and may not be available to all users. Contact the Contentstack support team; they will coordinate with the appropriate stakeholders to review eligibility.
A composition is the foundational unit of structure in Studio. It can represent a full page, a section of a page, or a reusable UI module. After creating a project, you use compositions to define layouts, bind content, and apply design rules.
A composition typically combines the following elements:
You can create multiple compositions within a project and bind content entries to them.
Studio supports two types of compositions: Linked and Freeform. Choosing the right type ensures your layout aligns with your content strategy.
A Linked Composition connects a page to a specific content type in your stack. Once linked, the composition dynamically renders all entries of that content type using the same linked composition, based on the URL opened.
Tip: Linked Compositions work best when a Content Type has multiple entries or when you want to build a shared template for entry-based pages.
For example, you are building a “Blog” section. You create a Linked Composition and connect it to the “Blog Posts” Content Type. Each blog post entry (e.g., /blog/hello-world, /blog/whats-new) dynamically uses this layout via the slug.
A Freeform Composition is not tied to a Content Type. It is ideal for static, standalone, or draft pages.
Tip: Start with a Freeform Composition if you don’t yet have content entries. You can convert it to a Linked Composition later.
For example, you are designing a one-off “Spring Campaign” landing page. Since it doesn’t pull data from any Content Type, you use a Freeform Composition and set the URL path as /campaigns/spring-2025.
Each composition type requires a URL structure:
Example: /company/about-us, where about-us is the slug.
Example: /campaigns/fall-2025
Tip: Use slugs for dynamic, entry-driven pages. Use paths for static, one-off pages.
Keeping composition URLs up to date ensures your site stays structured, relevant, and aligned with your goals.
To build layouts and structure content visually in Studio, you must start by creating a composition. A composition acts as a container where you can arrange UI components, bind CMS data, and apply design rules. You can create compositions from scratch or link them to existing content types for dynamic content rendering.
To create a composition, log in to your Contentstack account and perform the following steps:
Select the Content Type and specify a URL Slug (e.g., /blog/:slug).
Provide a custom URL Path (e.g., /marketing/launch).
After you create and publish a composition, use its composition UID to fetch the composition spec and render it in your front-end application. In a CSR app, fetch the spec in the browser using useCompositionData. In an SSR app, fetch the spec on the server (for example, in getServerSideProps) and render it using StudioComponent.
Use useCompositionData to fetch specOptions, then pass it to StudioComponent.
// src/App.tsx
import { StudioComponent, useCompositionData } from "@contentstack/studio-react";
export function Home() {
const { specOptions, isLoading, error, hasSpec } = useFetchSpecOptions({
compositionUid: "page", // Replace with your composition UID
});
if (isLoading) return <p>Loading...</p>;
if (error) return <div>Failed to fetch composition.</div>;
if (!hasSpec) return <p>Composition not found.</p>;
return <StudioComponent specOptions={specOptions} />;
}
This renders the layout and content as defined in Studio.
In SSR mode, fetch the composition spec on the server, extract styles, inject them into <Head>, and render the composition using StudioComponent.
// pages/index.tsx
import Head from "next/head";
import type { GetServerSidePropsContext } from "next";
import {
StudioComponent,
extractStyles,
StudioComponentSpecOptions,
} from "@contentstack/studio-react";
import { studioClient } from "../studio";
interface HomeProps {
studioProps: StudioComponentSpecOptions;
styleSheet: string;
}
export default function Home({ studioProps, styleSheet }: HomeProps) {
return (
<>
<Head>{styleSheet && <style>{styleSheet}</style>}</Head>
<StudioComponent specOptions={studioProps} />
</>
);
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
try {
const { query: searchQuery } = context;
const studioProps = await studioClient.fetchCompositionData({
searchQuery,
compositionUid: "page", // Replace with your composition UID
});
const styleSheet = extractStyles(studioProps.spec);
return {
props: {
studioProps,
styleSheet,
},
};
} catch (error) {
console.error("Error fetching composition data", error);
return { notFound: true };
}
}
Use useCompositionData as the primary method to load a composition with its spec and metadata.
Returns:
Parameters:
Example with all return values:
import { useCompositionData } from "@contentstack/studio-react";
export function Page() {
const {
specOptions,
seo,
hasSpec,
hasTemplate,
spec,
refetchSpec,
isLoading,
error,
} = useCompositionData(
{ compositionUid: "page" }, // compositionQuery (required)
{} // options (optional)
);
if (isLoading) return null;
if (error) return <p>Failed to fetch composition.</p>;
if (!hasSpec) return <p>Composition not found.</p>;
return (
<pre>{JSON.stringify({ seo, hasTemplate, spec: !!spec }, null, 2)}</pre>
);
}
You can update a composition’s metadata, such as its name, content type, URL slug, or URL path, directly from the composition listing page. This is different from editing the layout or bindings inside the canvas.
To edit a composition’s metadata, open your Studio project and perform the following steps:
Note: The UID of a composition cannot be edited.
Note: Converting between modes affects how the composition binds to entries. A linked composition binds to a single content type. A freeform composition can be reused across multiple content types.
Tip:
If a composition is no longer needed, you can delete it from your project. This helps reduce clutter and ensures that only relevant layouts are retained.
Warning: Once you delete a composition, it cannot be recovered.
To delete a composition, open a Studio project and perform the following steps:
As your project grows, organizing compositions becomes essential for ease of access and maintenance. Studio offers tools to search, rename, duplicate, and reorder compositions from the dashboard, helping you keep everything structured and discoverable.
From the project dashboard, you can:
Follow these guidelines to ensure scalable and maintainable compositions:
Compositions give you the flexibility to design, manage, and scale pages visually in Studio. Whether you’re building dynamic layouts or simple modules, keeping your compositions organized and up to date helps your team work faster and stay aligned.