Heads-up
Astro's built-in optimization is great for in-repo images. swiftimg makes sense once your image library outgrows the repo or you need responsive variants without checking 4× sizes in.
Step by step
1. Whitelist swiftimg in astro.config.mjs
Add the delivery hostname to `image.domains` so the component will accept it as a remote source.
astro.config.mjs // astro.config.mjs export default defineConfig({ image: { domains: ["i.swiftimg.com"] }, });2. Reference a swiftimg URL from a component
Use the `<Image />` component with a swiftimg URL and explicit width/height.
src/pages/index.astro --- import { Image } from "astro:assets"; --- <Image src="https://i.swiftimg.com/abc123.png" width={1200} height={630} alt="..." />3. Use transforms for responsive srcset
Add width/format query parameters to the swiftimg URL and pass it through `<picture>` with explicit sources.
Astro — FAQ
Does Astro's image cache still apply?
Astro caches generated variants of in-repo images. For remote swiftimg URLs, swiftimg's own global cache (1-year immutable) is what serves the bytes.
What about Astro on Vercel / Netlify?
Same setup — remote images are fetched from swiftimg regardless of host. No platform-specific image bills.
Can I use swiftimg with the legacy @astrojs/image integration?
The integration supports remote URLs, but the modern `astro:assets` API is the recommended path.
See also
Image hosting for Static sites (Hugo, Jekyll, Eleventy)
Offload images from your static-site repo to swiftimg. Smaller repo, faster builds, automatic WebP variants, and on-the-fly resizing — no plugin required.
Image hosting for Hugo
Reference swiftimg URLs from Hugo templates and content. Permanent URLs, automatic WebP, and no Hugo image processing on every build.
Image hosting for Eleventy (11ty)
Reference swiftimg URLs from Eleventy templates and Markdown. Permanent URLs, automatic WebP, and no @11ty/eleventy-img runtime needed.
swiftimg vs Cloudflare Images
A Cloudflare Images alternative: equivalent global delivery, without the per-image and per-delivery line items.
Ready to host your Astro images?
Start free, then unlock the full API, transforms, signed URLs, and a custom domain on the Developer plan.