{"record":{"id":"ce98e02495b79779","repo":"ueberdosis/tiptap","slug":"gethtmlfromfragment-can-only-be-used-in-a-browser","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/html/src/getHTMLFromFragment.ts","lineNumber":22,"sourceCode":"/**\n * Returns the HTML string representation of a given document node.\n *\n * @param doc - The document node to serialize.\n * @param schema - The Prosemirror schema to use for serialization.\n * @returns The HTML string representation of the document fragment.\n *\n * @example\n * ```typescript\n * const html = getHTMLFromFragment(doc, schema)\n * ```\n */\nexport function getHTMLFromFragment(\n  doc: PMNode,\n  schema: Schema,\n  options?: { document?: Document },\n): string {\n  if (typeof window === 'undefined') {\n    throw new Error(\n      '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.',\n    )\n  }\n\n  if (options?.document) {\n    const wrap = options.document.createElement('div')\n\n    DOMSerializer.fromSchema(schema).serializeFragment(\n      doc.content,\n      { document: options.document },\n      wrap,\n    )\n    return wrap.innerHTML\n  }\n\n  const wrap = window.document.createElement('div')\n\n  DOMSerializer.fromSchema(schema).serializeFragment(","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/ueberdosis/tiptap/blob/496d53afd7e4e3c7424b4749adeff4f45e27ddb0/packages/html/src/getHTMLFromFragment.ts#L4-L40","documentation":"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.\" thrown in ueberdosis/tiptap.","triggerScenarios":"Thrown at packages/html/src/getHTMLFromFragment.ts:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"496d53afd7e4e3c7424b4749adeff4f45e27ddb0","analyzedAt":"2026-08-26T22:41:43.400Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}