How to Build an Astro.js Image Component on Vercel
Published on
Last updated on
1 min read • --- views
Astro.js Image Component
When I built my linktree website I forgot to use Image component in
Astro.js.
I used the img tag instead. So after learning about the Image component in Astro.js, I decided to
add it.
<Image src={UserProfileImage} densities={[1, 2]} width="160" height="160" quality="max" alt="Serhii Shramko is eating pizza." />
And what do you think? It's works locally, but when I deployed it on Vercel, I got an error.
How to Fix the Error
Searching... 🔎
Powerful ChatGPT?
No, I found the solution on old and good GitHub.
And a little bit of documentation.
// Update astro.config.mjs with image service export default defineConfig({ image: { service: sharpImageService(), } });
// Install sharp package pnpm add sharp
Done and deployed. Now it works perfectly on Vercel.
How I built my linktree website you can read in my previous article.
New to Astro? Check out my comprehensive Astro Framework guide to get started.
You might also like:
My personal Linktree with Astro.js and Vercel
--- views
Learn how to build a fast link tree with Astro.js and Vercel. Set up a custom subdomain and implement analytics for performance insights.
How to decrease deployment time by 44% with pnpm
--- views
Migrate from npm to pnpm and cut your deployment time by 44%. Step-by-step guide covering installation, lockfile conversion, and CI/CD configuration.
What is Astro Framework?
--- views
Comprehensive guide to the Astro framework. Learn what makes it special, explore its core features, and understand why it's great for static sites.
Share it: