React example
A grid of images and their labels, read straight from object storage. No API route, no server component, no state library.
The hook
Open the Space once, then resolve the image track into URLs and the label track into a lookup:
The cancelled flag matters in StrictMode, where the effect runs twice in development.
The component
Every URL is content-addressed and immutable, so loading="lazy" plus the browser cache is the whole image-loading strategy. Nothing needs revoking, because nothing allocated a Blob.
Adding search
useGallery returns every record. To narrow it, run the search through SQL (npm 0.5.6+), not queryVector: in 0.5.8 queryVector returns anchors as plain numbers that can lose nanosecond precision, so they cannot be matched against item.anchor. SQL _anchor cells are exact bigints:
shown is in hit order. A hit with no image entry has no item and is skipped. Semantic search shows how to produce queryVector.
Bundler setup
Vite needs vite-plugin-wasm for the default import. Next.js needs experiments.asyncWebAssembly, or keep DreamDB on the server. Details in Install.