Skip to content

Installation

Before installing Annota, ensure you have:

  • Node.js 18 or higher
  • React 18+ / 19+ OR Svelte 5
  • A package manager (npm, pnpm, or yarn)

Annota provides identical functionality for both React and Svelte. The only difference is the reactive API (hooks vs stores).

React users get:

  • React hooks (useAnnotator, useAnnotations, useTool, etc.)
  • React components with JSX
  • Full TypeScript support
  • Optimized for React 18+ and React 19+
Terminal window
npm install annota openseadragon

Annota is written in TypeScript and includes full type definitions. For OpenSeadragon types:

Terminal window
npm install --save-dev @types/openseadragon

Import the required CSS in your app entry point:

React:

import "annota/dist/index.css";

Svelte:

<script>
import "annota/dist/index.css";
</script>

Or in your global CSS:

@import "annota/dist/index.css";

Create a simple test component:

import { AnnotaProvider, AnnotaViewer, Annotator } from "annota";
import { useState } from "react";
import "annota/dist/index.css";
function TestViewer() {
const [viewer, setViewer] = useState(null);
return (
<AnnotaProvider>
<div style={{ width: "800px", height: "600px" }}>
<AnnotaViewer
options={{
tileSources: {
type: "image",
url: "https://picsum.photos/1920/1080",
},
prefixUrl: "https://cdn.jsdelivr.net/npm/openseadragon@4/build/openseadragon/images/",
}}
onViewerReady={setViewer}
/>
<Annotator viewer={viewer} />
</div>
</AnnotaProvider>
);
}

Create a simple test component:

<script>
import { AnnotaProvider, AnnotaViewer, Annotator } from "annota/svelte";
import "annota/dist/index.css";
let viewer = $state(null);
</script>
<AnnotaProvider>
<div style="width: 800px; height: 600px;">
<AnnotaViewer
options={{
tileSources: {
type: "image",
url: "https://picsum.photos/1920/1080",
},
prefixUrl: "https://cdn.jsdelivr.net/npm/openseadragon@4/build/openseadragon/images/",
}}
onViewerReady={(v) => viewer = v}
/>
<Annotator {viewer} />
{/if}
</div>
</AnnotaProvider>

If you see an image viewer in either case, Annota is installed correctly!

For loading HDF5 annotation files:

Terminal window
npm install h5wasm

For the Segment Anything Model tool, you’ll need ONNX Runtime:

Terminal window
npm install onnxruntime-web

Now that Annota is installed, continue to: