astro-vercel-image

1.0.2 • Public • Published

Vercel Image Optimization for Astro

This is an integration for Astro that adds support for Vercel Image Optimization. Note: This integration currently does not support using the Vercel Adapter, to do that please referance the Vercel Image Optimization blog for more info.

Installation

npm install astro-vercel-image

Usage

There is two things to setup with this integration, the first is to add the astro-vercel-image plugin to your astro.config.mjs file. See Vercel Image Optimization Docs for more info on the options.

export default {
  integrations: [
    vercelImages({
      sizes: [640, 750, 828, 1080, 1200],
      domains: [],
      minimumCacheTTL: 60,
      formats: ["image/avif", "image/webp"],
      remotePatterns: [
        {
          protocol: "https",
          hostname: "^avatars1\\.githubusercontent\\.com$",
          pathname: "^/u/578259",
        },
      ],
    }),
  ],
};

The second thing to do is import the VercelImage component from astro-vercel-image/VercelImage.astro and use it in your components. Note: The VercelImage component width needs to in the list of sizes in the astro.config.mjs file.

---
import VercelImage from "astro-vercel-image/VercelImage.astro";
---

<div>
  <VercelImage src="/cat-image.jpg" alt="A photo of a cat" width={640} />
</div>

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i astro-vercel-image

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

5.9 kB

Total Files

6

Last publish

Collaborators

  • ~jcblw