Skip to content
Functiondiscord-component-embedv1.1.1

toComponentEmbedJson

Returns the component embed's JSON as a string. It escapes </ and <!-- to keep text in the card from closing the <script> tag early. Use it when your framework writes the tag itself and takes the JSON as its content.

Throws:

toComponentEmbedJson(root: EmbedElement): string
// a SolidStart route. the script needs the id discord:component-embed
<script id="discord:component-embed" type="application/vnd.discord.component-embed+json" innerHTML={toComponentEmbedJson(buildPostCard(post))} />