# use-auto-callback-ref

> An custom `useCallback` hook which returns a continuously updating ref object. This means the callback ref will always be the latest function. This can be useful for things like event handlers so you don't need to unsubscribe/resubscribe each time the cal

Latest version **2.0.1** (published 2026-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-auto-callback-ref
pnpm add use-auto-callback-ref
yarn add use-auto-callback-ref
bun add use-auto-callback-ref
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-03-29 |
| First published | 2023-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Liah |
| Maintainers | liammartens |

## Links

- npm: https://www.npmjs.com/package/use-auto-callback-ref
- Repository: https://github.com/LiahMartens/use-callback-ref
- Homepage: https://github.com/LiahMartens/use-callback-ref#readme
- Issues: https://github.com/LiahMartens/use-callback-ref/issues
- npm.io page: https://npm.io/package/use-auto-callback-ref

## Dependencies (1)

- [use-auto-callback-ref](https://npm.io/package/use-auto-callback-ref.md) ^2.0.0

## Recent versions

- 2.0.1 (latest) — 2026-03-29
- 2.0.0 — 2026-03-29
- 1.0.0 — 2023-01-08

## README

# use-auto-callback-ref

An custom `useCallback` hook which returns a continuously updating ref object.
This means the callback ref will always be the latest function.
This can be useful for things like event handlers so you don't need to unsubscribe/resubscribe each time the callback updates.

## Usage

```js
import { useCallbackRef } from "use-auto-callback-ref";

const ref = useCallbackRef(() => {}, []);

// this is just an example
useEffect(() => {
  // in this case if we were using a normal callback
  // we would have to unsubscribe and re-subscribe each time the handler updates
  // however with a callback ref we can simply call the function contained in the
  // ref, which will always be the latest one and we only have to subscribe once
  return emitter.subscribe(() => {
    ref.current();
  });
}, []);
```

---
_Source: https://npm.io/package/use-auto-callback-ref · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
