Framework Wrappers

// thin, reactive bindings for React, Svelte, and Vue

All three framework wrappers follow the same architecture: a <CadViewer> component that manages the core CadViewer lifecycle and syncs reactive props.

Comparison

FeatureReactSvelteVue
Component<CadViewer><CadViewer><CadViewer>
Hook/ComposableuseCadViewerโ€”useCadViewer
Peer depsReact 18/19Svelte 5Vue 3.5+
LicenseMITMITMIT

Common Props

All <CadViewer> components accept the same core props:

PropTypeDefaultDescription
fileFile \| ArrayBuffer \| string \| nullnullFile to load (reactive)
theme'dark' \| 'light''dark'Color theme
tool'pan' \| 'select' \| 'measure''pan'Active interaction tool
debugboolean \| DebugOptionsfalseDebug overlay
workerbooleanfalseWeb Worker parsing
formatConvertersFormatConverter[][]Format converters (e.g., DWG)
optionsCadViewerOptions{}Additional viewer options

Common Exposed Methods

All components expose these imperative methods:

MethodSignatureDescription
getViewer() => CadViewer \| nullAccess the core CadViewer instance
fitToView() => voidFit camera to drawing extents
getLayers() => DxfLayer[]Get all layers
setLayerVisible(name: string, visible: boolean) => voidToggle layer visibility

Re-exported Types

All wrappers re-export these types from @cadview/core for convenience:

import type {
	FormatConverter,
	SelectEvent,
	MeasureEvent,
	ViewTransform,
	DxfLayer,
	DxfDocument,
	DxfEntity,
	Tool,
	Theme
} from '@cadview/react'; // or @cadview/svelte, @cadview/vue

Choose Your Framework

  • React โ€” <CadViewer> component + useCadViewer hook
  • Svelte โ€” <CadViewer> Svelte 5 component
  • Vue โ€” <CadViewer> component + useCadViewer composable