LockOnMount

Acquires a record lock while mounted and releases it on unmount. Shows its children once the lock is held, a loading placeholder while requesting it, or the holder when another identity has it. Needs a realtime data provider with lock support.

Installation

pnpm dlx shadcn@latest add @chelone/lock-on-mount
Loading preview…

Acquires a record lock while mounted and releases it on unmount. Shows its children once the lock is held, a loading placeholder while requesting it, or the holder when another identity has it. Needs a realtime data provider with lock support.

See the realtime guide for provider setup and usage.

Props

PropTypeDefaultDescription
childrenReactNode—Shown only while this component holds the lock.
idIdentifier—Defaults to the id of the record context.
identityIdentifier—Defaults to the auth provider's identity.
loadingReactNode—Shown while the lock is requested. Defaults to a `Skeleton`.
lockedBy(lock: Lock) => ReactNode—Shown when another identity holds the lock. Defaults to an `Alert` naming the holder.
metaRecord<string, unknown>—
onLockError(error: Error) => void—Called with a failed lock or release. A new function every render never relocks.
resourcestring—Defaults to the resource context.