Skip to content
Functiondiscord-component-embed/reactv1.1.1

ComponentEmbed

Renders the <script> tag Discord reads for a component embed. Render this on the server or at build time because Discord does not run JavaScript. It works in the <head> or the <body>.

ComponentEmbed(
    { children },
    input: ComponentEmbedProps
): ReactElement
// app/[...slug]/page.tsx in Next.js
export default async function GuidePage({ params }: PageProps<'/[...slug]'>) {
    const page = await getGuidePage((await params).slug);

    // only Discord's crawler reads the <ComponentEmbed> tag
    return (
        <>
            <ComponentEmbed>
                <GuidePreview page={page} />
            </ComponentEmbed>
            <article>{page.body}</article>
        </>
    );
}

{ children }

{ children }