npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@socialtip/asset-proxy-astro

v0.3.1

Published

Astro image service for asset-proxy

Readme

@socialtip/asset-proxy-astro

An Astro image service that delegates image processing to an asset-proxy instance.

Implements Astro's ExternalImageService interface — no images are processed at build time. Instead, <Image> and getImage() calls produce URLs pointing to your asset-proxy deployment.

Installation

pnpm add @socialtip/asset-proxy-astro

Configuration

In your astro.config.mjs:

import { defineConfig } from "astro/config";

export default defineConfig({
  image: {
    service: {
      entrypoint: "@socialtip/asset-proxy-astro",
      config: {
        baseUrl: "https://assets.example.com",
      },
    },
  },
});

Config options

| Option | Type | Required | Description | | ------------------------- | --------- | -------- | --------------------------------------------------------------------------------------------------- | | baseUrl | string | Yes | Base URL of your asset-proxy instance. | | signingKey | string | No | Hex-encoded HMAC-SHA256 key for URL signing. Must be set together with signingSalt. | | signingSalt | string | No | Hex-encoded salt prepended to the path before HMAC signing. Must be set together with signingKey. | | encryptionKey | string | No | Hex-encoded 32-byte AES-256-CBC key for encrypting the source URL. | | deterministicEncryption | boolean | No | When true, derives the encryption IV from the source URL for stable/cacheable URLs. |

Usage

Once configured, Astro's built-in <Image> component and getImage() function will automatically route through asset-proxy:

---
import { Image } from "astro:assets";
---

<Image
  src="https://example.com/photo.jpg"
  width={800}
  height={600}
  format="webp"
  quality={80}
  alt="A photo"
/>

This renders an <img> tag whose src points to your asset-proxy instance:

https://assets.example.com/_/rs:fit:800:600/q:80/plain/https://example.com/photo.jpg@webp

Supported Astro props

| Prop | Mapped to | | --------- | ---------------------------------------------------------------------------------- | | width | resize width | | height | resize height | | quality | quality (numeric or preset: low = 30, mid = 50, high = 80, max = 100) | | format | Output format suffix (jpeg is normalised to jpg) | | fit | Resizing type (contain/scale-downfit, coverfill, fillforce) |

Custom <Image> component

The Astro image service only exposes the subset of proxy options that Astro's ImageTransform supports. For full access to all ~70 proxy options, use the custom <Image> component:

---
import Image from "@socialtip/asset-proxy-astro/Image.astro";
---

<Image
  src="https://example.com/photo.jpg"
  options={{
    resize: { type: "fill", width: 640, height: 480 },
    quality: 90,
    outputFormat: "avif",
    blur: 2,
    gravity: "ce",
  }}
  alt="A photo"
/>

The component reads baseUrl and signing/encryption settings from your astro.config.mjs image service config automatically. No need to pass config unless you want to override it per-image.

The component accepts:

  • src (required) — the source image/video URL
  • config — override the global AssetProxyServiceConfig for this image (optional — defaults to the config from astro.config.mjs)
  • options — a Partial<ParsedUrlInput> object with proxy processing options (e.g. resize, crop, gravity, blur, sharpen, monochrome, framerate, etc.)
  • Standard HTML <img> attributes (alt, class, loading, decoding, etc.)

It defaults to loading="lazy" and decoding="async", matching Astro's built-in behaviour.

Custom <Video> component

The <Video> component works identically to <Image> but renders a <video> tag:

---
import Video from "@socialtip/asset-proxy-astro/Video.astro";
---

<Video
  src="https://example.com/clip.mp4"
  options={{
    resize: { type: "fit", width: 1280, height: 720 },
    outputFormat: "mp4",
    framerate: 30,
    cut: 10,
    mute: true,
  }}
  controls
  autoplay
  muted
/>

The component accepts:

  • src (required) — the source video URL
  • config — override the global AssetProxyServiceConfig for this video (optional — defaults to the config from astro.config.mjs)
  • options — a Partial<ParsedUrlInput> object with proxy processing options (e.g. resize, framerate, cut, mute, outputFormat, etc.)
  • Standard HTML <video> attributes (controls, autoplay, muted, loop, poster, width, height, etc.)

getImageUrl helper

For cases where you need the URL string directly (e.g. in CSS, srcset, or server endpoints), use getImageUrl:

import { getImageUrl } from "@socialtip/asset-proxy-astro";

const url = getImageUrl(
  {
    src: "https://example.com/photo.jpg",
    resize: { type: "fit", width: 800, height: 600 },
    quality: 80,
    outputFormat: "webp",
  },
  { baseUrl: "https://assets.example.com" },
);