import { lazy, Suspense, useEffect, useState } from "react"; import type { MonacoAutoCompletion, MonacoEditorClientProps } from "./MonacoEditor.client"; const MonacoEditorClient = lazy(() => import("./MonacoEditor.client")); export type { MonacoAutoCompletion }; export default function MonacoEditor(props: MonacoEditorClientProps) { // The editor is strictly client-only: ./MonacoEditor.client pulls in the // browser-only monaco runtime, so importing it during SSR throws and the // streaming render sets HTTP 500 on every page that mounts an editor (the page // still hydrates fine on the client, which is why this stayed invisible until a // readiness test asserted the response status). Render the placeholder on the // server AND the first client render — keeping markup identical so hydration // matches — then swap in the real editor after mount, so the client bundle is // the only place that ever imports it. const [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); if (!mounted) { return
; } return (