React library
Hooks and events
Load gallery data and respond to lightbox interactions.
useGallery must be rendered under GalleryProvider.
const {
gallery,
items,
activeAsset,
isLoading,
error,
openLightbox,
closeLightbox,
refetch,
} = useGallery({ galleryId: 'gallery_uuid' });You can provide gallery to avoid a client request, or use galleryId/slug for client-side retrieval. queryOptions allows application-specific TanStack Query behavior without changing the library's query key or fetch function.
The hook tracks gallery_view when a gallery resolves and image_view when a lightbox item opens. Use the returned track function for supported application interactions.
useGalleryContext is available for provider-owned lightbox state and the configured client. It throws when used outside GalleryProvider, which makes missing provider wiring visible during development.