Skip to content
Skip to content
Skip to content

Library

A React hook that measures how long every interaction really takes, in production.

stars
2,140
downloads
48,200
license
MIT
Install
npm install use-latency
City avenues at dusk seen from above

README.mdMIT

use-latency is a 900 byte React hook around the Event Timing API. It tells you which interactions were slow for a real visitor, and which component was under their finger at the time.

Usage

tsx
import { useLatency } from "use-latency"

export function App() {
  useLatency({
    over: 200,
    report: (entry) => send("/vitals", entry),
  })
  return <Routes />
}

What you get

  • entry.duration in milliseconds, measured from input to the next paint
  • entry.target as a short selector, and the nearest component name in development
  • entry.kind: pointer, keyboard or drag

Why it exists

It started as a debugging script on a payments dashboard. Lab tools said the table was fine; the people using it said it was not. The hook proved them right in an afternoon.

No dependencies. It does nothing at all in browsers without the Event Timing API.

Library

A React hook that measures how long every interaction really takes, in production.

stars
2,140
downloads
48,200
license
MIT
Install
npm install use-latency
City avenues at dusk seen from above

README.mdMIT

use-latency is a 900 byte React hook around the Event Timing API. It tells you which interactions were slow for a real visitor, and which component was under their finger at the time.

Usage

tsx
import { useLatency } from "use-latency"

export function App() {
  useLatency({
    over: 200,
    report: (entry) => send("/vitals", entry),
  })
  return <Routes />
}

What you get

  • entry.duration in milliseconds, measured from input to the next paint
  • entry.target as a short selector, and the nearest component name in development
  • entry.kind: pointer, keyboard or drag

Why it exists

It started as a debugging script on a payments dashboard. Lab tools said the table was fine; the people using it said it was not. The hook proved them right in an afternoon.

No dependencies. It does nothing at all in browsers without the Event Timing API.

Library

A React hook that measures how long every interaction really takes, in production.

stars
2,140
downloads
48,200
license
MIT
Install
npm install use-latency
City avenues at dusk seen from above

README.mdMIT

use-latency is a 900 byte React hook around the Event Timing API. It tells you which interactions were slow for a real visitor, and which component was under their finger at the time.

Usage

tsx
import { useLatency } from "use-latency"

export function App() {
  useLatency({
    over: 200,
    report: (entry) => send("/vitals", entry),
  })
  return <Routes />
}

What you get

  • entry.duration in milliseconds, measured from input to the next paint
  • entry.target as a short selector, and the nearest component name in development
  • entry.kind: pointer, keyboard or drag

Why it exists

It started as a debugging script on a payments dashboard. Lab tools said the table was fine; the people using it said it was not. The hook proved them right in an afternoon.

No dependencies. It does nothing at all in browsers without the Event Timing API.

Start a project

Three quick picks so the first reply is useful. You finish the message on the contact page.

What do you need?

Rough budget

brief.tsdraft, not sent

Brief so far: nothing picked yet

or write to hello@sorenhale.dev

Nothing is sent from this page. Your picks are kept in this browser tab and wait for you on the contact form.

Start a project

Three quick picks so the first reply is useful. You finish the message on the contact page.

What do you need?

Rough budget

brief.tsdraft, not sent

Brief so far: nothing picked yet

or write to hello@sorenhale.dev

Nothing is sent from this page. Your picks are kept in this browser tab and wait for you on the contact form.

Start a project

Three quick picks so the first reply is useful. You finish the message on the contact page.

What do you need?

Rough budget

brief.tsdraft, not sent

Brief so far: nothing picked yet

or write to hello@sorenhale.dev

Nothing is sent from this page. Your picks are kept in this browser tab and wait for you on the contact form.

Footer

Local time, Oslo

Footer

Local time, Oslo

Footer

Local time, Oslo

Create a free website with Framer, the website builder loved by startups, designers and agencies.