Manual Installation
Add reactuse to your project without relying on a framework-specific guide.
Install the package
bash
npm install @siberiacancode/reactusebash
yarn add @siberiacancode/reactusebash
pnpm add @siberiacancode/reactusebash
bun add @siberiacancode/reactuseConfigure path aliases
Add baseUrl and paths to your tsconfig.json (or jsconfig.json) so imports resolve correctly:
json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}Adjust the @/* path to match your project structure (e.g. "./*" if you have no src folder).
Run the CLI
Run the useverse init command to setup your project:
bash
npx useverse@latest initThis will create a configuration file reactuse.json in your project and configure where hooks are generated (e.g. @/shared/hooks).
Add hooks
Add hooks to your project with the CLI:
bash
npx useverse@latest add useBooleanThen import and use them:
tsx
import { useBoolean } from '@/shared/hooks';
const App = () => {
const [on, toggle] = useBoolean();
return (
<div>
<button type='button' onClick={() => toggle()}>
Toggle
</button>
<p>{on.toString()}</p>
</div>
);
};If you prefer not to use the CLI, you can import hooks directly from the package:
tsx
import { useBoolean } from '@siberiacancode/reactuse';