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.
Studio lets you visually design, configure, and render web experiences by combining prebuilt or custom components, CMS-managed content, and design system tokens, without hand-writing HTML or CSS for each page.
This setup guide walks you through integrating Studio into a React project, from installing SDKs to rendering your first composition. By the end of this guide, you’ll have a working configuration that:
Before you begin, ensure you have:
Studio requires two SDKs:
This SDK provides the tools to fetch and render compositions from Studio.
Run one of the following commands in your project directory:
npm i @contentstack/studio-react
Or
yarn add @contentstack/studio-react
Studio uses this SDK internally to fetch your content from the CMS.
npm i @contentstack/delivery-sdk
Or
yarn add @contentstack/delivery-sdk
These tokens authenticate your front end to fetch published and preview content from Contentstack.
To create a Delivery and Preview token, log in to your Contentstack account and perform the following steps:
Tip: If you are on the Management Tokens tab, you can press “Alt + O” (Windows) or “Option + O” (Mac) to navigate to the Delivery Tokens tab.
A new token appears in both the Delivery Token and Preview Token fields. You can copy the tokens for later use in your SDK configuration.
Create a configuration file (e.g., src/studio/index.ts) to store your Studio setup.
// src/studio/index.ts
import contentstack from "@contentstack/delivery-sdk";
const stack = contentstack.stack({
apiKey: "api_key",
deliveryToken: "delivery_token",
environment: "environment",
live_preview: {
preview_token: "preview_token",
enable: true,
},
});Note:
In your main file (e.g., src/index.ts), import the Studio config:
import { studioSdk } from "@contentstack/studio-react";
studioSdk.init({
stackSdk: stack,
});This ensures the SDKs are initialized before your app renders any compositions.
To activate the configuration, import the index.ts in your application’s main file:
// src/index.ts
import "./studio";This ensures the SDKs are initialized before your app renders any composition.
The Studio Spec contains:
In your main component (App.tsx), use the useFetchSpecOptions hook to retrieve it.
// src/App.tsx
import { useCompositionData } from "@contentstack/studio-react";
export function Home() {
const { specOptions, isLoading, error } = useCompositionData({
compositionUid: "page", // Replace with your composition UID
});
}Once you have the spec, pass it to StudioComponent to render the layout.
// src/App.tsx
import { StudioComponent, useCompositionData } from "@contentstack/studio-react";
export function Home() {
const { specOptions, isLoading, error, hasSpec } = useFetchSpecOptions({
compositionUid: "page",
});
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 exactly as defined in Studio.
If you are using React Router or similar, you can fetch compositions dynamically based on the URL rather than hardcoding UIDs:
After completing the configuration steps, confirm that Studio is working as expected in your local environment.
Start your local development server to load your React or Next.js application.
npm start
Or
yarn start
This will compile your application and launch it on http://localhost:3000.
Navigate to your local URL (e.g., http://localhost:3000) and look for the composition.
If your stack has Live Preview enabled:
Tip: If changes don’t appear, verify your token settings and ensure the enable property is set to true in the live_preview configuration.
You’ve now connected your front-end application to Studio. With your setup complete, you can:
As your project grows, Studio helps maintain consistency, accelerate iteration, and keep content creators and developers in sync.