How to get custom components via API in my next app?

hello Greetings!!

I am trying to fetch html content using HTML API from builder.io, I am getting all html with style but unable to get my custom components…

Is there any way that i can get my custom component html as well?

I am using content api from API Explorer…

Hi @rinkal, Welcome to Builder.io Forum!

Yes, it is expected if you are using our HTML API then custom components are not supported through the API. There is however a workaround with web components that lets you add custom components to your pages.

Registering Web Components for Use in Builder’s Visual Editor

The way custom component rendering works is that any component will need to be registered and imported in the same context where the SDK is rendering the content.

Our HTML API will return what we render on our servers, meaning that we will not have a user’s custom components available within the same context.

There are ways for you to create custom components within Builder that you could access from the HTML API. For example, you could create a symbol with any child elements, classes, CSS and JS you need and then use the HTML API to access that. Or similarly, that symbol placed on a page will be accessible as well.

Let us know if you face any issues while achieving this!

hello @garima

Thanks for your response. but I have tried with creating symbol for custom component and tried to access via HTML API but that didn’t work.

Also i have tried with registering webcomponent but facing so many reference error like customElements, window, HTMLElement not defined…

Also i have one query like if i got success on web component creation. It will display on builder.io dashboard just like my custom components ?

Hi @rinkal, We’re sorry for any inconvenience. Feel free to mail us at support@builder.io with your error details so the builder tech team can assist you to resolve issues and achieve this functionality!