DEV Community

PixelVault
PixelVault

Posted on

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

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 } from "astro:assets";
---

<Image
  src="https://img.pixelvault.dev/proj_xyz789/img_abc123.jpg"
  width={800}
  height={450}
  widths={[400, 800, 1600]}
  sizes="(max-width: 800px) 100vw, 800px"
  alt="Hosted on PixelVault"
/>
Enter fullscreen mode Exit fullscreen mode

Docs: https://pixelvault.dev/docs/astro/
Source: https://github.com/pixelvault-dev/astro

Free tier: 200 MB, 500 uploads/month, no credit card. Feedback and issues welcome.

Top comments (0)