
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
web-vitals-react-hook
Advanced tools
Bring web vitals quickly into your react project
May thanks to Stafan Judis for his web-vitals-element where i borrowed a few lines and ideas 😁
npm i web-vitals-react-hook
You can use the hook or use the component
import { useWebVitals } from 'web-vitals-react-hook'
const metrics = useWebVitals() // uses all metrics: CLS FCP FID LCP TTFB
or define your own list
const metrics = useWebVitals(['FCP', 'TTFB'])
The metrics you get will include the values from web-vitals plus the evaluation.
Most valueble props:
{
name,
explainerURL,
longName,
supported,
rating,
unit,
value,
}

The component will give you a list with name, linked short name and value.
import { WebVitals } from 'web-vitals-react-hook'
<WebVitals />
<WebVitals vitals={['FCP', 'TTFB']} />
To style the element you can either override the internal components
for example:
<WebVitals ValueComponent={YourCustomValue} />
You can also style the internal components with emotion
import styled from '@emotion/styled'
import { WebVitals, Value } from 'web-vitals-react-hook'
const CustomValue = styled(Value)`
font-weight: bold;
`
<WebVitals ValueComponent={CustomValue} />
Or add your css to the classes
.WebVitals {
...
}
.WebVitals-name {
...
}
.WebVitals-shortName {
...
}
.WebVitals-link {
...
}
.WebVitals-value {
...
}
If you're having issues using this component or have an idea how to optimize this module, please open an issue.
This project is released under MIT license.
FAQs
react hook using web-vitals
The npm package web-vitals-react-hook receives a total of 2 weekly downloads. As such, web-vitals-react-hook popularity was classified as not popular.
We found that web-vitals-react-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.