Registry / testing / inspreact

inspreact

JSON →
library1.2.2jsnpmunverified

A lightweight, TypeScript-first React utility library (v1.2.2, 2025) providing commonly used hooks (useToggle, useCounter, useLocalStorage, useDebounce, useWindowSize, useThrottle, usePrevious, useClickOutside, useCopyToClipboard, useOnlineStatus, useTheme, useTimeout, useKeyPress) and helpers (deepClone, isEmpty, randomId, classNames, truncate, capitalize). Ships TypeScript types. Designed for rapid React development with zero external dependencies. Differentiators: theme hook with localStorage persistence, comprehensive set of hooks (13+), and small bundle size.

npm install inspreact
INSTALL
IMPORT
SIG · INSPREACT
I
inspreact
testingjavascriptv1.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useToggle
import { useToggle } from 'inspreact'
import useToggle from 'inspreact'
Named export, not default. Use destructured import.
useLocalStorage
import { useLocalStorage } from 'inspreact'
const { useLocalStorage } = require('inspreact')
ESM-only; CommonJS require may not work in all bundlers.
deepClone
import { deepClone } from 'inspreact'
import * as inspreact from 'inspreact'; inspreact.deepClone()
Direct named import preferred; namespace import works but is verbose.

Demonstrates useCounter, useDebounce, useCopyToClipboard, and isEmpty helper.

import { useCounter, useDebounce, useCopyToClipboard, isEmpty } from 'inspreact'; import React from 'react'; function QuickStart() { const { count, increment, reset } = useCounter(0); const debouncedCount = useDebounce(count, 500); const [copied, copy] = useCopyToClipboard(); return ( <div> <p>Count: {count} (debounced: {debouncedCount})</p> <button onClick={increment}>Increment</button> <button onClick={reset}>Reset</button> <button onClick={() => copy('Hello')}> {copied ? 'Copied!' : 'Copy'} </button> <p>Is empty? {String(isEmpty([]))}</p> </div> ); }
Debug
Known issues
gotchauseTheme persists theme in localStorage and updates document.body.dataset.theme; custom theme values must be handled in CSS.
fix
Ensure CSS rules match dataset.theme values (e.g., [data-theme='dark']).
affects: >=1.0.0
gotchauseLocalStorage throws silently in environments without localStorage (e.g., SSR) if not guarded.
fix
Wrap usage in a check: typeof window !== 'undefined' or use a try-catch.
affects: >=1.0.0
gotchauseClickOutside does not clean up event listeners if ref changes frequently; may cause memory leaks.
fix
Stabilize ref with useRef or useCallback.
affects: >=1.0.0
deprecatedNo deprecation notices as of v1.2.2.
gotchadeepClone does not handle circular references; may cause stack overflow.
fix
Use a library like lodash cloneDeep for circular objects.
affects: >=1.0.0
Errors
Common errors & fixes
Module ""inspreact"" has no exported member 'useToggle'.
Wrong import syntax or named export misspelling.
fix
Use import { useToggle } from 'inspreact' (case-sensitive).
Cannot read properties of undefined (reading 'useLocalStorage')
Using CommonJS require or improper import.
fix
Switch to ESM import: import { useLocalStorage } from 'inspreact'.
useDebounce is not returning debounced value
Missed that useDebounce returns debounced value, not a function.
fix
Use const debouncedValue = useDebounce(value, delay); not useDebounce(callback, delay).
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
inspreact — npm install inspreact · libregistry