import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { localEngine } from '@embedpdf/engine'; // The engine is created synchronously and costs nothing until first use, so // a module-scope `const engine = …` is safe, even under SSR. Only opening a // document does real work: the UI renders at t≈0. const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin()]; // The local engine opens bytes: fetch lazily, under the loading tab. const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; export default function App() { return (
{/* Document UI is defined over a document: gate it on having one. */} Loading…

}> {() => }
); }