Copy-paste React hooks, utilities, and patterns. One snippet per problem.
A simple React hook to debounce a value with configurable delay. Useful for search inputs and expensive updates.
Persist state in localStorage with React. Syncs across tabs and survives refresh.
A small React hook for boolean toggle state. Cuts down boilerplate in components.
Access the previous value of a prop or state in React. Useful for comparisons and animations.
Detect when an element enters or leaves the viewport. Useful for lazy loading and scroll animations.
Responsive values with min and max using CSS clamp(). One line for fluid typography or spacing.
Set aspect ratio on any element with the native aspect-ratio property. No wrapper divs.
Format a Date or string for display. Locale-aware, no heavy libraries.
Convert a string to a URL-safe slug. Handles accents, spaces, and special characters.
Limit how often a function runs. Useful for scroll, resize, or input handlers.
Copy text to the clipboard with a Promise-based API and fallback for older browsers.
Read environment variables with a fallback. Avoids undefined in Node or edge runtimes.