Skip to main content
Home

A library of reusable React hooks, components, and utilities built by ZL Asica.

This package works with Cloudflare Workers, Node.js, Bun, BrowsersIt is unknown whether this package works with Deno
This package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
88%
Published
6 days ago (0.7.0)
f
assignUUID

Assigns a UUID to each element in the array.

f
backToTop

Scrolls to the top of the page or a specified vertical position.

f
camelCaseToKebabCase

Converts a camelCase string to kebab-case.

f
capitalize

Capitalizes the first letter of a string. Just like String.prototype.charAt(0).toUpperCase(), but without the need to call slice(1) to get the rest of the string.

f
chunkArray

Chunks an array into smaller arrays of a specified size.

f
clamp

Clamps a number to a specified range.

f
copyToClipboard

Copies the given text to the clipboard.

f
deepClone

Creates a deep clone of an object using structuredClone.

f
formatDate

Formats a Date object into a string according to the specified format.

f
generateUniqueId

Generates a unique identifier by hashing an array of input strings, a timestamp, and a random value.

f
getDayOfWeek

Gets the day of the week for a given date.

f
getRelativeDay

Gets a relative day description based on a given date, e.g., 'Yesterday', 'Last Friday', '2 weeks ago Thursday'.

f
getScrollPosition

Retrieves the current scroll position of the window.

f
isAllZeroArray

A helper function to check if an number array contains all zeros or empty.

f
isEmpty

Checks if a value is an empty object, array, string, or falsy value.

f
isObject

Determines whether a value is a non-array object.

f
isSameDay

Checks if two Date objects fall on the same calendar day.

f
lerp

Linearly interpolates between two numbers.

f
mapRange

Maps a number from one range to another.

f
mergeObjects

Deeply merges two objects into a single object.

f
omit

Omits specified keys from an object.

f
pasteFromClipboard

Retrieves text from the clipboard.

f
pick

Picks specified keys from an object.

f
randomFloat

Generates a random floating-point number between min and max.

f
randomInt

Generates a random integer between min and max (inclusive).

f
removeSpecialCharacters

Removes special characters from a string, preserving letters, numbers, and spaces.

f
reverseString

Reverses the characters in a string.

f
toSnakeCase

Converts a string to snake_case.

f
truncate

Truncates a string to a specified length, appending '...' if truncated.

f
truncateToNearestWord

Truncate a string to the nearest whole word within a given length limit. If the string exceeds the max length, it appends '...' at the end. If no space is found within the truncated string, and the string is longer than the max length, it will truncate the string at the max length and append '...'.

f
uniqueArray

Removes duplicate elements from an array.

v
useAdaptiveEffect

A hook that adapts to the environment: uses useLayoutEffect on the client side and useEffect on the server side. This ensures compatibility with both SSR and CSR environments.

f
useArray

A custom React hook for managing an array state with helper functions to modify it.

f
useAsync

A custom React hook to handle asynchronous functions with state management for loading, error, and result. Useful for API calls or other asynchronous operations.

f
useBoolean

A custom React hook for managing a boolean state with helper functions. Provides functions to toggle the value, set it to true, or set it to false.

f
useClickOutside

A custom React hook that detects clicks or touch events outside the specified target element. It is useful for closing dropdowns, modals, or menus when a user interacts outside the specified element. The handler function is called when the user clicks or touches outside the referenced element. Optionally, events can be debounced for better performance in rapid interaction scenarios.

f
useCounter

A custom React hook for managing a numeric counter state with helper functions. Provides functions to increment, decrement, and reset the counter value.

f
useDebounce

useDebounce

f
useDebouncedCallback

A custom React hook to debounce a callback function. The debounced function will only be executed after a specified period of inactivity.

f
useEventListener

A custom React hook for attaching an event listener to a target element with automatic cleanup. This hook is useful for adding event listeners to DOM elements or the window object. It also supports optional debouncing to limit how often the handler is invoked.

f
useFetch

A custom React hook to fetch data from an API and manage its state. Automatically handles loading, error, and result states. Supports cancellation of the fetch operation on component unmount.

f
useHideOnScrollDown

Custom hook to toggle visibility on scroll. It hides the element when scrolling down and shows it when scrolling up.

f
useHover

A custom React hook to track whether a referenced element is being hovered.

f
useIntersectionObserver

A custom React hook that uses the Intersection Observer API to determine if an element is visible within the viewport.

f
useInViewport

A custom React hook to check if a DOM element is within the viewport. Allows specifying an offset to consider elements near the edge of the viewport as "visible".

f
useIsBottom

A custom React hook to track whether a specific element (or the page) is scrolled to the bottom. It supports global targets (e.g., window or document.documentElement) and specific HTMLElements.

f
useIsTop

A custom React hook to track whether a specific element (or the page) is scrolled to the top. It supports global targets (e.g., window or document.documentElement) and specific HTMLElements.

f
useKeyPress

A custom React hook to track whether a specific key is pressed. This hook is useful for implementing keyboard shortcuts or detecting specific key actions in your application. The key detection is case-sensitive and supports optional debouncing for optimized performance during rapid key presses.

f
useLocalStorage

A custom React hook for managing state that is synchronized with localStorage. Provides error handling by returning a status object along with the value and setter.

f
useObfuscatedEmail

A React hook that safely obfuscates an email address to prevent spam bots from detecting it in the source HTML or static JavaScript.

f
usePolling

A custom React hook to execute a callback function at a fixed interval. Supports dynamically updating the callback or stopping the polling by setting the delay to null.

f
useScrollPosition

A custom React hook to track the vertical scroll position of a specific element or the window. Automatically updates whenever the user scrolls.

f
useSessionStorage

A custom React hook for managing state that is synchronized with sessionStorage. Provides error handling by returning a status object along with the value and setter.

f
useTheme

Custom React hook to manage dark mode with automatic expiration.

f
useThrottle

A custom React hook to throttle the execution of a callback function. Ensures the callback is only executed at most once every specified delay.

f
useTimeout

Hook that runs a function after a specified delay. The timeout resets if the dependencies change.

f
useToggle

A custom React hook for managing a boolean toggle state. Provides the current value and a function to toggle it between true and false.

f
useWindowSize

A custom React hook to track the current window size. Automatically updates whenever the window is resized.

f
assignUUID

Assigns a UUID to each element in the array.

f
backToTop

Scrolls to the top of the page or a specified vertical position.

f
camelCaseToKebabCase

Converts a camelCase string to kebab-case.

f
capitalize

Capitalizes the first letter of a string. Just like String.prototype.charAt(0).toUpperCase(), but without the need to call slice(1) to get the rest of the string.

f
chunkArray

Chunks an array into smaller arrays of a specified size.

f
clamp

Clamps a number to a specified range.

f
copyToClipboard

Copies the given text to the clipboard.

f
deepClone

Creates a deep clone of an object using structuredClone.

f
formatDate

Formats a Date object into a string according to the specified format.

f
generateUniqueId

Generates a unique identifier by hashing an array of input strings, a timestamp, and a random value.

f
getDayOfWeek

Gets the day of the week for a given date.

f
getRelativeDay

Gets a relative day description based on a given date, e.g., 'Yesterday', 'Last Friday', '2 weeks ago Thursday'.

f
getScrollPosition

Retrieves the current scroll position of the window.

f
isAllZeroArray

A helper function to check if an number array contains all zeros or empty.

f
isEmpty

Checks if a value is an empty object, array, string, or falsy value.

f
isObject

Determines whether a value is a non-array object.

f
isSameDay

Checks if two Date objects fall on the same calendar day.

f
lerp

Linearly interpolates between two numbers.

f
mapRange

Maps a number from one range to another.

f
mergeObjects

Deeply merges two objects into a single object.

f
omit

Omits specified keys from an object.

f
pasteFromClipboard

Retrieves text from the clipboard.

f
pick

Picks specified keys from an object.

f
randomFloat

Generates a random floating-point number between min and max.

f
randomInt

Generates a random integer between min and max (inclusive).

f
removeSpecialCharacters

Removes special characters from a string, preserving letters, numbers, and spaces.

f
reverseString

Reverses the characters in a string.

f
toSnakeCase

Converts a string to snake_case.

f
truncate

Truncates a string to a specified length, appending '...' if truncated.

f
truncateToNearestWord

Truncate a string to the nearest whole word within a given length limit. If the string exceeds the max length, it appends '...' at the end. If no space is found within the truncated string, and the string is longer than the max length, it will truncate the string at the max length and append '...'.

f
uniqueArray

Removes duplicate elements from an array.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.