@unlazy/react
v2.0.1
Published
React lazy loading library for placeholder images
Maintainers
Readme
@unlazy/react
React component for unlazy, the universal lazy loading library leveraging native browser APIs.
- 🎀 Native: Utilizes the
loading="lazy"attribute - 🌊 BlurHash & ThumbHash support: SSR & client-side decoding
- ⚡ Core Web Vitals-aware: Eager-priority path for above-the-fold images, dev-mode LCP warning
- 🎟
<picture>: Art direction with automaticsizes
Installation
# pnpm
pnpm add @unlazy/react
# npm
npm i @unlazy/reactQuick Start
import { UnLazyImage } from '@unlazy/react'
export function Hero() {
return (
<UnLazyImage
blurhash="LKO2:N%2Tw=w]~RBVZRi};RPxuwH"
srcSet="image-320w.jpg 320w, image-640w.jpg 640w"
autoSizes
onImageLoad={img => console.log('Loaded:', img.src)}
/>
)
}Documentation
📖 Read the full documentation, including hash-based placeholders, Core Web Vitals, and SSR.
Migrating from v1
See the migration guide for breaking changes in v2.
License
MIT License © 2023-PRESENT Johann Schopplich
