Lighthouse measures four things: performance, accessibility, best practices, SEO. For a Vite SPA, accessibility is the one you have least excuse to neglect — it's mostly a discipline of using the right HTML.
Running Lighthouse
Open Chrome DevTools → Lighthouse tab → pick categories (performance, accessibility, best practices, SEO) → run on Production mode (start with npm run preview, not the dev server). Get a score per category and a list of issues with documentation links.
The performance score
Driven by metrics: LCP (largest contentful paint), TBT (total blocking time), CLS (cumulative layout shift). For SPAs, LCP and TBT usually dominate. Wins: code splitting (Track 8 lesson 2), lazy-load below-the-fold images, font-display: swap, eliminate render-blocking JS in <head>.
The accessibility floor (what every SPA needs)
- Semantic HTML —
<button>not<div onClick>,<nav>/<main>/<article>for structure,<label>for every input. - Keyboard navigation — every interactive element reachable by Tab, with visible focus rings (don't
outline: nonewithout a replacement). - Color contrast — text passes WCAG AA (4.5:1 for normal text, 3:1 for large). Lighthouse flags failures with specific elements.
- ARIA when HTML isn't enough —
aria-labelfor icon-only buttons,role="alert"for error toasts,aria-livefor streamed content. - Page titles & meta — every route should set
document.title(or use a library likereact-helmet-async).
The best-practices floor
HTTPS in production. No console errors. No deprecated APIs. Source maps available for error tracking. CSP headers (Content Security Policy) for production. Lighthouse flags the misses.