Install @danixsoft/hooks
npm install @danixsoft/hooks@danixsoft/hooks is a collection of 44 React hooks with no runtime dependencies, written in TypeScript and safe to render on a server. This page takes you from an empty project to a working hook in about two minutes.
Requirements
- React 18 or later, including React 19. React is a peer dependency, so your app controls the version.
- Node 18 or later for the build tooling. The hooks themselves run in the browser and have no Node requirement.
- TypeScript 5 or later if you use TypeScript. Types ship with the package — there is no separate
@typesinstall.
Installation
That is the whole install. The package has no runtime dependencies, so nothing else enters your lockfile.
Quick start
Every hook is a named export from the package root. Import what you need and call it like any other hook.
Next.js App Router
Hooks only run in Client Components. Add"use client" at the top of any file that calls one — the same rule React applies to useState. Keep that directive as far down the tree as possible so less of your app has to hydrate.A slightly larger example, combining three hooks to build a debounced, responsive search box with persisted history:
Good hooks to start with
TypeScript
The package is written in TypeScript and ships its own declarations. In most cases you never write a type annotation — the generics infer from the arguments you pass.
"dark" and rejects setTheme("light"). Widening the generic is the fix.Server-side rendering
Every hook that reads a browser API guards it and returns a stable value during server rendering. That means no window is not defined crash during the build, and no hydration mismatch on the client.
The consequence worth knowing: browser-derived values are only correct after hydration. useWindowSize returns undefined on the server, useMediaQuery returns false, and useLocalStorage returns the initial value until the effect runs. This is deliberate — it is what keeps the first render identical on both sides.
When a flash is unacceptable
For something as visible as a theme, showing the default first is not good enough. You need a blocking inline script in the document head — the full technique is in SSR-safe hooks in Next.js.Tree shaking
The package is published as ES modules and marked sideEffects: false, so any modern bundler — webpack, Vite, Rollup, esbuild, Turbopack — drops the hooks you do not import.
There is no deep-import path to remember and no /dist/useDebounce convention — importing from the package root is already optimal.
Testing
The hooks are ordinary functions, so renderHook from React Testing Library tests them directly. Nothing has to be mocked to use the library itself.
environment: "jsdom" in Vitest, or testEnvironment: "jsdom" in Jest.Where to go next
- Browse all 44 hooks — the full catalogue with a live demo on every page.
- The React hooks cheat sheet — built-in and custom hooks in one reference.
- SSR-safe hooks in Next.js — the hydration rules in depth.
- API reference — generated directly from the source types.
- FAQ — licensing, compatibility and support questions.