arkynChangelogGuides
docs / services / to-html

toHtml

The toHtml function converts a rich text value array into an HTML string.

Import

ts

import { toHtml } from "@arkyn/components/toHtml";
Learn how subpath and root imports differ in How do I use imports.

Parameters

The function accepts the following parameter:

richTextValue (required)

Array of rich text nodes to be serialized into HTML.
Type: RichTextValue

Usage example

The function returns an HTML string generated by serializing each rich text node and joining the result.
Type: string

typescript

import { toHtml } from "@arkyn/components/toHtml";
const richText = [
{
type: "paragraph",
children: [{ text: "Hello world", bold: true }],
},
];
const html = toHtml(richText);
console.log(html);
// Output: "<p><strong>Hello world</strong></p>"

Notes

  • The function serializes each node individually and concatenates the resulting HTML strings.
  • An empty rich text array returns an empty string.
  • Use this function when you need to persist or render editor content as HTML.
Related in Services
On this page
    arkyn