SSE Hooks

useScrollLock

GitHub
A custom hook that locks and unlocks scroll.

Installation

npx sse-hooks add use-scroll-lock

Usage

example.ts
import { useScrollLock } from "./{hooks file}";

// Lock the scroll when the modal is mounted, and unlock it when it's unmounted
useScrollLock();

API

Parameters

Prop Default Type
options

{}

UseScrollLockOptions

Options to configure the hook, by default it will lock the scroll automatically.

Returns

Return Value Default Type
isLocked-

boolean

Whether the scroll is locked.

lock-

() => void

Lock the scroll.

unlock-

() => void

Unlock the scroll.

Types Aliases

No specific type aliases defined for this component.

Changelog

c165d — feat: enhance useRoleGuard and useSSR hooks with additional options and documentation

30da4 — feat: add new hooks and their metadata

cf13e — feat: add custom hooks for step navigation, ternary dark mode, timeout, toggle, unmount, and window size

Built with Love • © 2026