Imposia
API Reference

API Reference

Choose the React, Core, or Viewer contract you need, with shared package and lifecycle guidance.

Use this reference after you have rendered a first document. Choose a package page for exact components, controllers, options, and lifecycle constraints.

Package map

PackagePurposePrimary APIs
@imposia/reactReact integrationImposiaPageViewer, ImposiaDocument, ImposiaPublicationViewer, both lifecycle hooks
@imposia/coreFramework-neutral pagination and publicationsmountPageDocument, mountPublication, prepareDocument
@imposia/viewerPresent committed pages or load a PDFmountPageViewer, mountViewer, deep-link helpers
@imposia/clientCombined framework-neutral entry pointRe-exports the primary Core and Viewer integration APIs

Import @imposia/react/styles.css once when you use the React package.

Choose an API

Lifecycle and errors

SituationResult
First generation pendingcurrent is undefined; React state is loading.
Update pending after commitThe previous commit stays visible and in React state.
Newer update startsOlder active generation rejects with AbortError.
Caller abortsRelated generation/export rejects with DOM AbortError.
Update fails after commitPromise rejects; previous commit remains current.
Controller destroysWork aborts, resources/frame are released, and current clears.

ImposiaError extends Error with readonly code: string. Handle cancellation separately from reportable failures:

try {
  await controller.update(nextSource, { signal });
} catch (error) {
  if (error instanceof DOMException && error.name === "AbortError") return;
  if (error instanceof ImposiaError) console.error(error.code, error.message);
  throw error;
}

Viewer methods generally ignore calls that cannot operate in their current state. Ownership-sensitive calls throw: page Viewer mount/refresh validate the canonical iframe, Publication navigation rejects stale destinations, reader selection rejects foreign thumbnails, and inspector selection rejects foreign warnings.

On this page