Performance
Core Web Vitals thresholds
Core Web Vitals good thresholds are LCP at most 2500 ms, INP at most 200 ms and CLS at most 0.1 (unitless). Assess each metric at its 75th percentile for each device cohort; all three must meet their targets. This pure helper classifies already-aggregated synthetic values, not individual visits or a measured site. Invalid or missing observations are unknown. Source: https://web.dev/articles/vitals. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
classifyVitals({LCP, INP, CLS}) // local model; LCP and INP in msWorking Example
Example Snippetnextjs
export function classifyVitals(p75:{LCP?:number;INP?:number;CLS?:number}){ const limits={LCP:2500,INP:200,CLS:0.1} as const; const keys=['LCP','INP','CLS'] as const; const states=keys.map(k=>{const v=p75[k];return typeof v!=='number'||!Number.isFinite(v)||v<0?'unknown':v<=limits[k]?'good':'not-good';}); return states.includes('not-good')?'not-good':states.includes('unknown')?'unknown':'good';}