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

@imagekit/astro

v1.0.1

Published

Astro SDK for ImageKit.io - optimized image & video delivery with transformations

Readme

ImageKit.io Astro SDK

npm version License: MIT Twitter Follow

Introduction

ImageKit Astro SDK plugs ImageKit.io into Astro's built-in image pipeline. It allows you to:

  • Render images with Astro's <Image /> and <Picture /> components, served from ImageKit with automatic optimization, responsive srcset, and lazy loading.
  • Apply real-time transformations (resize, crop, focus, quality, format) using URL parameters.
  • Apply AI-powered transformations such as background removal, generative fill, and smart cropping via the transformation prop.
  • Render optimized <Video /> tags backed by ImageKit.
  • Generate OpenGraph / Twitter Card meta tags pointing to ImageKit URLs with the <OgImage> component (or the getOgImageUrl() helper for custom layouts).
  • Generate server-side upload authentication parameters with getUploadAuthParams().

How it works

The SDK ships as an Astro integration that registers a custom image service. Once added to astro.config.mjs, it takes over Astro's image pipeline for the whole site — <Image />, <Picture />, getImage(), and even markdown ![]() images all flow through it.

The service is host-aware. For each image, it inspects the src and routes the request to one of two backends:

  1. ImageKit fast-path — when src is an ImageKit URL (your urlEndpoint host, any additionalEndpoints host, or a bare path like "folder/photo.jpg"), the service builds an ImageKit URL with the requested transformations and points the browser at https://ik.imagekit.io/... directly. No server processing, no /_image round-trip — just a CDN-cached URL with ?tr=... parameters.

  2. Sharp fallback — when src is a local Astro asset (import of an image, or markdown ![](../foo.jpg)) or an absolute URL on a non-ImageKit host (e.g. an allow-listed third-party domain), the service delegates to Astro's bundled sharp service. The image is processed at build time (or on-demand by Astro's /_image endpoint in SSR) exactly as if you had no integration installed.

This means you can drop the integration into an existing Astro project without breaking any of its existing local-asset usage. Local assets keep working via sharp; ImageKit URLs get the full ImageKit treatment.

Installation

npm install @imagekit/astro

If you call upload() (or other helpers) from @imagekit/javascript directly in your code, also add it to your project so strict package managers (e.g. pnpm) can resolve it:

npm install @imagekit/javascript

TypeScript support

The SDK is written in TypeScript and ships with full type definitions. The integration uses Astro's injectTypes() helper to register ImageKit-specific props (urlEndpoint, transformation, queryParameters, transformationPosition) on the Astro.CustomImageProps namespace, so <Image />, <Picture />, and getImage() get full autocomplete and type-checking for these props.

Run astro sync (or start the dev server) once after installing so Astro picks up the injected types. For editor support in .astro files, install the Astro VS Code extension; for type-checking from the CLI, use @astrojs/check.

Loading images from your ImageKit Media Library

You can use Astro Content Collections together with the @imagekit/nodejs SDK to power gallery/listing pages directly from your ImageKit Media Library, without hand-maintaining a list of URLs.

Install the Node SDK as a dev dependency (it's only used at build time):

npm install -D @imagekit/nodejs

Define a collection backed by client.assets.list(). The Node SDK returns an array of File | Folder objects directly, so pass type: 'file' to exclude folders and fileType: 'image' to limit results to images. Shape each entry as { id, ...data } — Astro's content layer treats the top-level id as the entry key and validates everything else against your schema:

// src/content.config.ts
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import ImageKit from '@imagekit/nodejs';
import type { Files } from '@imagekit/nodejs/resources/files/files';

const client = new ImageKit({
  privateKey: import.meta.env.IMAGEKIT_PRIVATE_KEY,
});

const gallery = defineCollection({
  loader: async () => {
    const assets = await client.assets.list({
      type: 'file',       // exclude folders
      fileType: 'image',  // only image files
      skip: 0,
      limit: 50,
    });

    return assets
      .filter((asset): asset is Files.File =>
        asset.type === 'file' && !!asset.fileId && !!asset.url
      )
      .map((asset) => ({
        id: asset.fileId ?? '',
        url: asset.url ?? '',
        width: asset.width ?? 0,
        height: asset.height ?? 0,
        name: asset.name ?? '',
        tags: asset.tags ?? [],
      }));
  },
  schema: z.object({
    url: z.string().url(),
    width: z.number(),
    height: z.number(),
    name: z.string(),
    tags: z.array(z.string()),
  }),
});

export const collections = { gallery };

After adding the collection, run astro sync (or start the dev server) so Astro generates the collection types used by getCollection().

Render with <Image> from astro:assets — the integration's image service generates the IK CDN URL with the correct transformations:

---
import { Image } from 'astro:assets';
import { getCollection } from 'astro:content';

const photos = await getCollection('gallery');
---
{photos.map(({ data }) => (
  <Image src={data.url} width={data.width} height={data.height} alt={data.name} />
))}

Keep your privateKey in a server-only env var (e.g. IMAGEKIT_PRIVATE_KEY in .env, never prefixed with PUBLIC_). Collection loaders run at build time (or in SSR endpoints), never in the browser.

Documentation

Refer to the ImageKit official documentation for setup instructions, configuration options, and the full API reference.