Overview
useCollections is the primary hook for working with a user’s collection library. It automatically fetches the root collection on mount, loads sub-collections as you navigate deeper, and exposes actions for creating, updating, deleting, and saving entities.
Requires an authenticated user. The hook reads user and project context from the nearest
SublayProvider.Usage Example
Parameters
This hook accepts no required parameters. Pass an empty object or nothing.Returns
Direct child collections of
currentCollection. Loaded automatically when currentCollection changes.Navigate into a sub-collection. Pushes to the internal navigation stack and fetches its children.
({ entityId, collectionId }: { entityId: string; collectionId?: string }) => Promise<{ saved: boolean; inSpecificCollection?: boolean; collections: Array<{ id: string; name: string }> }>
Check whether an entity is saved in any collection. If
collectionId is provided, also returns inSpecificCollection indicating whether it is in that specific folder.Create a new sub-collection inside the current collection.
Rename a collection.
update accepts { name: string }. The root collection cannot be renamed.Delete a collection. The root collection cannot be deleted. Navigation automatically moves to the parent after deletion.
Remove an entity from the current collection.

