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 a query first and keep the anchors:
Hits come back ordered by score, so sort shown by the hit order rather than the index order if ranking matters to you. Semantic search shows where queryVector's input comes from.
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.