Create a Custom Component in Sitecore XM Cloud using the Content SDK

In the previous blog, we saw how to set up and start working with the Sitecore Content SDK.
Now, as promised, we’re back with the next blog on how to create component using the Content SDK and integrate it into your app.

In this guide, we’ll create a custom component, register it in Sitecore XM Cloud, and make it available inside the Page Builder using the Content SDK.

1. Create a Component Item in Content Editor

In Content Editor, navigate to:

/sitecore/layout/Renderings/Project/DemoProject

Clone an existing component or use Derivative Rendering to create a new one

- Go to the rendering path you want to clone

- /sitecore/layout/Renderings/Feature/DemoSite/CustomForm

- Right click → Scripts → Clone Rendering


A screenshot of a computer

AI-generated content may be incorrect.

Provide details in the clone wizard:

- Rendering Name → RichTextBlockA

- Module/Site → select your project/site name

- For other tabs (Data, Parameters, etc.) → you can inherit or copy to change it as needed

- Click Proceed

 A screenshot of a computer

AI-generated content may be incorrect.

 A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Once created, you’ll see your new Rendering item under mentioned path:

 A screenshot of a computer

AI-generated content may be incorrect.

 2. Add Your Component to Available Renderings

- Navigate to : sitecore/Content/DemoSite/Presentation

- Right-click Available Renderings → Insert → Available Renderings

 

A screenshot of a computer

AI-generated content may be incorrect.

 

Enter a name, e.g. MyCustomForm, and click OK

A screenshot of a computer

AI-generated content may be incorrect.

Under the Data section → click Edit

A screenshot of a computer

AI-generated content may be incorrect.

In the dialog, navigate to: 

Layout/Renderings/Project/DemoProject 

Double-click your component to add it. Click OK

A screenshot of a computer

AI-generated content may be incorrect.

Save your changes.

 

Back in the Available Renderings item:

Check the checkbox - Group renderings in sections according to Available Renderings items in the site

Save the changes

 

A screenshot of a computer

AI-generated content may be incorrect.

3. Verify Component in Page Builder

Now open Pages (Sitecore Page Editor or Local Editing Host)

You’ll see your new component listed here

 

A screenshot of a computer

AI-generated content may be incorrect.

 

A screenshot of a computer

AI-generated content may be incorrect.

but it might be disabled with a tooltip saying: “This component is not implemented in your editing host.”

This happens because Content SDK requires manual component registration (unlike JSS SDK, which auto-registers).

Next, we’ll fix that.

4. Scaffold the Component

- Run the Content SDK CLI command to generate a new component:

sitecore-tools project component scaffold MyCustomForm

- This will generate a component under src/components/MyCustomForm

A screen shot of a computer program

AI-generated content may be incorrect.

Note: There’s a known issue — the generated code misses the JSX import.
Fix it by editing the first line of code as below.

import React, { JSX } from 'react';

and the error will be gone

 A screen shot of a computer program

AI-generated content may be incorrect.

This is not done yet, we need to register the component

5. Register Component

This step is unique to the Content SDK as compared to JSS SDK

- Open your component map file under src/lib/component-map.ts to register the component

A screenshot of a computer

AI-generated content may be incorrect.

- Add your component import and mapping:

A screen shot of a computer program

AI-generated content may be incorrect.

6. Sync and Test

Now, sync your changes and restart your local editing host.

In the Page Builder, you’ll see your new component enabled and ready to add on any page

We have now successfully built our first XM Cloud Component using the Content SDK!

Next, we will learn to

- Connect component fields dynamically from Sitecore Content items

- Add Rendering Parameters for styling options

- Use GraphQL Layout Service

 

Comments

Popular posts from this blog

Migrating from Sitecore JSS SDK to Content SDK – Best Practices and Pitfalls

Beginner’s Guide: Step-by-Step Local Installation for Sitecore XM Cloud

Setting Up Sitecore Headless with Next.js in Disconnected Mode