ueberdosis/tiptap · error
getHTMLFromFragment can only be used in a browser environmen
Error message
getHTMLFromFragment can only be used in a browser environment If you want to use this in a Node environment, use the `@tiptap/html/server` import instead.
What it means
Error "getHTMLFromFragment can only be used in a browser environment If you want to use this in a Node environment, use the `@tiptap/html/server` import instead." thrown in ueberdosis/tiptap.
Source
Thrown at packages/html/src/getHTMLFromFragment.ts:22
/**
* Returns the HTML string representation of a given document node.
*
* @param doc - The document node to serialize.
* @param schema - The Prosemirror schema to use for serialization.
* @returns The HTML string representation of the document fragment.
*
* @example
* ```typescript
* const html = getHTMLFromFragment(doc, schema)
* ```
*/
export function getHTMLFromFragment(
doc: PMNode,
schema: Schema,
options?: { document?: Document },
): string {
if (typeof window === 'undefined') {
throw new Error(
'getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.',
)
}
if (options?.document) {
const wrap = options.document.createElement('div')
DOMSerializer.fromSchema(schema).serializeFragment(
doc.content,
{ document: options.document },
wrap,
)
return wrap.innerHTML
}
const wrap = window.document.createElement('div')
DOMSerializer.fromSchema(schema).serializeFragment(View on GitHub (pinned to 496d53afd7)
When it happens
Trigger: Thrown at packages/html/src/getHTMLFromFragment.ts:22 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ueberdosis/tiptap@496d53afd7 (2026-08-26).
Data as JSON: /api/errors/ce98e02495b79779.
Report an issue: GitHub.