npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tri-hooks

v1.0.2

Published

A comprehensive, tree-shakable hooks library for React, Vue, and Angular

Downloads

299

Readme

tri-hooks

A comprehensive, tree-shakable hooks library for React, Vue, and Angular with identical functionality and TypeScript support. Covers all major browser APIs and common frontend patterns.

🚀 Features

  • Tree-shakable: Import only what you need
  • Framework Agnostic: Same API across React, Vue, and Angular
  • TypeScript Ready: Strictly typed with comprehensive type definitions
  • Browser API Coverage: Implements all major browser APIs
  • Production Ready: SSR-safe, proper cleanup, edge-case handling
  • Performance Optimized: Efficient implementations with proper memoization
  • Cross-Platform: Consistent behavior across all supported frameworks

📦 Installation

One install for everything:

npm install tri-hooks

There is only one package. After installing, you can use hooks in two ways:

| How you use it | What you do | |----------------|-------------| | All at once | Import many hooks from tri-hooks (React) or tri-hooks/vue or tri-hooks/angular | | Single hook (separately) | Import one hook from its path, e.g. tri-hooks/hooks/state-ui/useToggle/react — your bundle stays small (tree-shaking) |

Use all hooks at once (single import)

Import multiple hooks from the main package or from a framework-specific entry. Best when you use several hooks in the same app.

| Framework | Import from | Example | |-----------|-------------|---------| | React | tri-hooks or tri-hooks/react | import { useToggle, useClipboard } from 'tri-hooks' | | Vue | tri-hooks/vue | import { useToggle, useClipboard } from 'tri-hooks/vue' | | Angular | tri-hooks/angular | import { useToggle, useClipboard } from 'tri-hooks/angular' |

Use hooks separately (tree-shaking, smaller bundles)

Import only the hook you need from its path. Bundlers will include just that hook.

// React
import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/react';

// Vue
import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/vue';

// Angular
import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/angular';

| Use case | Recommendation | |----------|-----------------| | Use many hooks | Import from tri-hooks (React) or tri-hooks/vue or tri-hooks/angular | | Use one or two hooks, want smallest bundle | Import from the hook path, e.g. tri-hooks/hooks/state-ui/useToggle/react |

🎯 Categories

State & UI

Data & Async

DOM & Events

Storage

Device & Connectivity

Animation

Browser APIs

Media

Notifications

  • useToast - Toast notification management

Forms

🔧 Usage

React

All at once:

import { useToggle, useClipboard } from 'tri-hooks';
// or: import { useToggle, useClipboard } from 'tri-hooks/react';

function MyComponent() {
  const [value, toggle] = useToggle(false);
  const { copy, copied } = useClipboard();
  return (
    <button onClick={toggle}>{value ? 'ON' : 'OFF'}</button>
  );
}

Separately (tree-shaken):

import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/react';

function MyComponent() {
  const [value, toggle] = useToggle(false);
  return <button onClick={toggle}>{value ? 'ON' : 'OFF'}</button>;
}

Vue

All at once:

import { useToggle, useClipboard } from 'tri-hooks/vue';

export default {
  setup() {
    const { value, toggle } = useToggle(false);
    const { copy, copied } = useClipboard();
    return { value, toggle, copy, copied };
  },
};

Separately (tree-shaken):

import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/vue';

export default {
  setup() {
    const { value, toggle } = useToggle(false);
    return { value, toggle };
  },
};

Angular

All at once:

import { Component } from '@angular/core';
import { useToggle, useClipboard } from 'tri-hooks/angular';

@Component({
  selector: 'app-my-component',
  template: `<button (click)="toggle()">{{ value() ? 'ON' : 'OFF' }}</button>`,
})
export class MyComponent {
  private toggleHook = useToggle(false);
  clipboard = useClipboard();

  value = this.toggleHook.value;
  toggle = this.toggleHook.toggle;
}

Separately (tree-shaken):

import { Component } from '@angular/core';
import { useToggle } from 'tri-hooks/hooks/state-ui/useToggle/angular';

@Component({
  selector: 'app-my-component',
  template: `<button (click)="toggle()">{{ value() ? 'ON' : 'OFF' }}</button>`,
})
export class MyComponent {
  private toggleHook = useToggle(false);
  value = this.toggleHook.value;
  toggle = this.toggleHook.toggle;
}

🛠️ Framework-Specific Patterns

Angular Implementation Notes

  • Signals First: Angular hooks prioritize signals for reactivity
  • RxJS When Needed: Uses observables only when continuous streams or cancellation is required
  • Injectable Services: Shared logic exposed as injectable services
  • Minimal Observable Usage: Avoiding heavy RxJS unless necessary

React Implementation Notes

  • Functional Hooks: Pure functional approach with useCallback/useMemo
  • Proper Effects: useEffect for side effects, useLayoutEffect when needed
  • Typed Returns: Comprehensive TypeScript return type definitions

Vue Implementation Notes

  • Composition API: Pure composition functions
  • Reactive References: Using ref/computed/watch as appropriate
  • Lifecycle Management: Proper cleanup via onUnmounted

🧪 Testing

Each hook includes comprehensive tests covering:

  • Normal usage scenarios
  • Edge cases and error conditions
  • Cleanup and resource management
  • Cross-framework behavioral consistency

📄 License

MIT License - Free to use in commercial and personal projects.

🤝 Contributing

Contributions are welcome! Please see our Contributing Guide for details.

🆘 Support

For support, please open an issue in the repository or contact the maintainers.