⚠️ AlabJS is under active development and not yet production-ready. APIs may change before v1.0. Feel free to explore, contribute, or star the repo.
Skip to content

The <Image> component automatically converts images to WebP, generates a responsive srcset, and supports blur-up placeholders — all powered by the AlabJS Rust core (no sharp dependency).

Basic usage

tsx
import { Image } from "alabjs/components";

<Image src="/hero.jpg" alt="Hero" width={1200} height={600} />

LCP images

Mark the above-the-fold image as the LCP element to set loading="eager" and fetchpriority="high":

tsx
<Image src="/hero.jpg" alt="Hero" width={1200} height={600} priority />

Blur-up placeholder

Generate a tiny Base64 placeholder on the server for an instant-load feel:

ts
// In a server function:
import { defineServerFn } from "alabjs/server";
import { generateBlurPlaceholder } from "alabjs/components";

export const getHero = defineServerFn(async (_, { publicDir }) => {
  const blur = await generateBlurPlaceholder("/hero.jpg", publicDir);
  return { blur };
});
tsx
// In the page:
<Image src="/hero.jpg" alt="Hero" width={1200} height={600} blurDataURL={blur} />

Props

PropTypeDescription
srcstringPath relative to /public or absolute URL
altstringAlt text (required)
widthnumberIntrinsic width in px
heightnumberIntrinsic height in px
sizesstringsizes attribute (default: ${width}px)
prioritybooleanLCP image — sets eager loading
qualitynumber1–100, default 80
blurDataURLstringBase64 blur placeholder
classNamestringAdditional class names

How it works

Images are served from /_alabjs/image?src=...&w=...&q=...&fmt=webp. The Rust napi binding decodes, resizes, and encodes the image on a blocking thread pool — the Node.js event loop is never blocked.

Released under the MIT License.