
Research
/Security News
11 Malicious NuGet Tools Pose as Game Cheats to Drop a Windows Host-Surveillance Payload
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.
A lightweight collection of custom React hooks to simplify common tasks in your React applications. Hookbase provides reusable solutions for managing state, handling side effects, and interacting with browser APIs.
A lightweight collection of custom React hooks to simplify common tasks in your React applications. Hookbase provides reusable solutions for managing state, handling side effects, and interacting with browser APIs.
You can run Hookbase using npx or install it via npm:
npx hookbase
Or install it as a dependency:
npm install hookbase
Import the desired hooks into your React components:
import { useBoolean } from "@/hooks/use-boolean";
useBooleanManages a boolean state with utility functions to toggle, set to true, or set to false.
defaultValue (boolean, optional): Initial boolean value. Defaults to false. Must be true or false.An object with the following properties:
value (boolean): Current boolean state.setValue (function): Updates the boolean state.setTrue (function): Sets the state to true.setFalse (function): Sets the state to false.toggle (function): Toggles the state between true and false.import { useBoolean } from "@/hooks/use-boolean";
function ToggleComponent() {
const { value, setTrue, setFalse, toggle } = useBoolean(false);
return (
<div>
<p>State: {value.toString()}</p>
<button onClick={setTrue}>Set True</button>
<button onClick={setFalse}>Set False</button>
<button onClick={toggle}>Toggle</button>
</div>
);
}
useCopyToClipboardHandles copying text to the clipboard with a temporary "copied" state indicator.
delay (number, optional): Duration (in milliseconds) the isCopied state remains true after copying. Defaults to 2000.A tuple containing:
copy (function): Async function to copy text to the clipboard. Returns true on success, false on failure.isCopied (boolean): Indicates if text was recently copied.import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
function CopyButton() {
const [copy, isCopied] = useCopyToClipboard();
const handleCopy = async () => {
const success = await copy("Hello, World!");
console.log(success ? "Copied!" : "Copy failed");
};
return <button onClick={handleCopy}>{isCopied ? "Copied!" : "Copy Text"}</button>;
}
useDocumentTitleUpdates the document's title dynamically.
title (string): The title to set for the document.None.
import { useDocumentTitle } from "@/hooks/use-document-title";
function Page() {
useDocumentTitle("My Page Title");
return <h1>Hello, World!</h1>;
}
useIntervalRuns a callback function at specified intervals.
callback (function): Function to execute on each interval.delay (number | null): Interval duration in milliseconds. If null or not a number, the interval is paused.None.
import { useInterval } from "@/hooks/use-interval";
function Timer() {
const [count, setCount] = React.useState(0);
useInterval(() => {
setCount(count + 1);
}, 1000);
return <p>Count: {count}</p>;
}
useIsomorphicLayoutEffectA conditional alias for useLayoutEffect (client-side) or useEffect (server-side) to handle isomorphic rendering.
Use as a direct replacement for React.useLayoutEffect or React.useEffect.
import { useIsomorphicLayoutEffect } from "@/hooks/use-isomorphic-layout-effect";
function Component() {
useIsomorphicLayoutEffect(() => {
console.log("Effect ran");
return () => console.log("Cleanup");
}, []);
return <div>Isomorphic Effect</div>;
}
useTimeoutExecutes a callback after a specified delay.
callback (function): Function to execute after the delay.delay (number | null): Delay in milliseconds. If null or not a number, the timeout is paused.None.
import { useTimeout } from "@/hooks/use-timeout";
function AlertComponent() {
useTimeout(() => {
alert("Timeout completed!");
}, 3000);
return <p>Waiting for timeout...</p>;
}
useToggleManages a boolean toggle state with a toggle function.
defaultValue (boolean, optional): Initial boolean value. Defaults to false.A tuple containing:
value (boolean): Current boolean state.toggle (function): Toggles the state between true and false.setValue (function): Updates the boolean state.import { useToggle } from "@/hooks/use-toggle";
function ToggleSwitch() {
const [isOn, toggle] = useToggle(false);
return <button onClick={toggle}>{isOn ? "On" : "Off"}</button>;
}
useUnmountExecutes a callback when the component unmounts.
func (function): Function to execute on unmount.None.
import { useUnmount } from "@/hooks/use-unmount";
function Component() {
useUnmount(() => {
console.log("Component unmounted");
});
return <div>Hello, World!</div>;
}
useCounterManages a numeric counter with increment, decrement, and reset functions.
initialValue (number, optional): Initial counter value. Defaults to 0.An object with the following properties:
count (number): Current counter value.increment (function): Increments the counter by 1.decrement (function): Decrements the counter by 1.reset (function): Resets the counter to the initial value.setCount (function): Updates the counter value.import { useCounter } from "@/hooks/use-counter";
function Counter() {
const { count, increment, decrement, reset } = useCounter(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
<button onClick={decrement}>Decrement</button>
<button onClick={reset}>Reset</button>
</div>
);
}
useMousePositionTracks the mouse position relative to the document and a referenced element.
Position: { x: number; y: number; elementX?: number; elementY?: number; elementPositionX?: number; elementPositionY?: number }A tuple containing:
state (Position): Current mouse position with optional element-relative coordinates.ref (React.Ref): Reference to attach to an HTML element for relative positioning.import { useMousePosition } from "@/hooks/use-mouse-position";
function MouseTracker() {
const [position, ref] = useMousePosition();
return (
<div ref={ref} style={{ height: "200px", border: "1px solid black" }}>
<p>
Mouse X: {position.x}, Y: {position.y}
</p>
<p>
Element X: {position.elementX ?? "N/A"}, Y: {position.elementY ?? "N/A"}
</p>
</div>
);
}
MIT License
FAQs
A lightweight collection of custom React hooks to simplify common tasks in your React applications. Hookbase provides reusable solutions for managing state, handling side effects, and interacting with browser APIs.
The npm package hookbase receives a total of 1 weekly downloads. As such, hookbase popularity was classified as not popular.
We found that hookbase demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.

Research
/Security News
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.