For developers

The viewer of Kasane is available as the package iiif-kasane, to put on your own site (MIT license). This page shows three ways to use it, each with a live viewer and its code: as React components, as the HTML tag <iiif-kasane>, and in Astro.

In each example, the tabs switch between the preview (a live viewer) and the code.

Install

The package is published on npm as iiif-kasane. Install three.js and the other 3D packages even if you show only images: your bundler resolves them, but the browser fetches them only when a 3D Scene is shown. The tag needs no install.

npm install iiif-kasane
npm install react react-dom jotai three three-stdlib @react-three/fiber @react-three/drei gsap

Package on npm

React: Viewer

The simplest way. Viewer fills its parent: give the parent a height and pass className="h-full". iiifContent is a manifest URL or a IIIF Content State.

Other props include locale (ja / en), theme (light / dark / auto), target to show a given Canvas from outside, and onSelect to hear which Canvas is shown.

React: the parts in your own layout

Inside ViewerProvider, place the parts (CanvasView for the display, AnnotationList, Metadata, …) in any layout. The parts share one state: choosing an annotation in the list moves the view, and the metadata follows the page turns. Your own components read the same state with useViewer() (PageLabel in the example).

Write the layout with your own CSS. The package’s style.css holds only the classes the parts use, and they apply only inside the viewer.

The tag: <iiif-kasane>

A page without any framework can use the viewer as a tag by loading one script; React is inside it. Set the height with CSS or --iiif-viewer-height, and the colors with the --iiif-viewer-* variables. Each version stays at its own URL, so you can pin one.

Its attributes are iiif-content, locale, theme and options (JSON, e.g. {"panelOpen":false,"pager":false}). Changing an attribute updates the viewer.

The share menu of the viewer writes the embed code for a given item. About structure, sharing and embedding

Astro

Both ways work in Astro. tag.astro sends the tag as plain HTML, and the script turns it into a viewer in the browser (the preview shows this). parts.astro puts FreeLayout.tsx from “the parts in your own layout” on the page as a React island; the viewer reads the browser (WebGL, the window size), so it is rendered with client:only="react".

The whole example (how to run it is in its README): packages/iiif-viewer/examples/astro

More