How to Build an Astro.js Image Component on Vercel
Published on
NaN1 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.
You might also like:
My personal Linktree with Astro.js and Vercel
--- views
Learn how to build a fast, efficient link tree website using Astro.js, deploy it with Vercel, set up a custom subdomain, and implement Vercel Analytics for performance insights.
How to decrease deployment time by 44% with pnpm
--- views
Learn how to efficiently migrate your project from npm to pnpm with this guide.
What is Astro Framework?
--- views
Astro is a new Javascript framework, so discover what makes it special and what are its core features.
Share it: