Menu

Host and optimize Astro images on a CDN with @pixelvault-dev/astro
📰

Host and optimize Astro images on a CDN with @pixelvault-dev/astro

DEV Community: astro·PixelVault·6 days ago
#6sv7ZPS4
#devtoastro#devto#dev#astro#pixelvault
Reading 0:00
15s threshold

I just released @pixelvault-dev/astro , an integration for Astro 5 and 6 with zero runtime dependencies. It ships three pieces you can use together or alone:

A typed PixelVaultImage component with responsive srcset and automatic WebP/AVIF.

A custom image service, so Astro's built-in <Image /> and <Picture /> offload resizing to the edge (no Sharp download at build time).

A Content Layer loader that syncs your media into a typed collection.

Install:

npm install @pixelvault-dev/astro

Enter fullscreen mode

Exit fullscreen mode

Then add pixelvault() to integrations in astro.config.mjs :

// astro.config.mjs import { defineConfig } from "astro/config" ; import pixelvault from "@pixelvault-dev/astro" ;

export default defineConfig ( { integrations : [ pixelvault ( { // Optional custom domains connected to your PixelVault projects: domains : [ "cdn.example.com" ] , } ) , ] , } ) ;

Enter fullscreen mode

Exit fullscreen mode

And render PixelVault URLs with Astro's standard <Image /> :

--- import { Image }…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.