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 🙏

© 2025 – Pkg Stats / Ryan Hefner

staticdelivr

v1.0.0

Published

StaticDelivr simplifies image delivery by optimizing performance through CDN integration, format conversion, and dynamic resizing. Perfect for React applications.

Readme

StaticDelivr

StaticDelivr is a lightweight React library for optimizing image delivery by leveraging StaticDelivr's CDN. It simplifies image optimization with support for resizing, quality adjustments, and format conversions, ensuring your application delivers the best possible image performance.

Features

  • Seamless integration with React.
  • Dynamic resizing and quality optimization of images.
  • Automatic format conversion to modern formats like WebP and AVIF.
  • Easy configuration with customizable base URL.
  • Support for both absolute and relative image paths.

Installation

Install the package via npm:

npm install staticdelivr

Or using yarn:

yarn add staticdelivr

Usage

Basic Usage

import React from 'react';
import { StaticDelivrImage, StaticDelivr } from 'staticdelivr';

// Configure the base URL for relative image paths
StaticDelivr.set({ baseURL: 'https://example.com/images/' });

const App = () => (
  <div>
    <StaticDelivrImage
      src="local/image.png"
      width={800}
      height={600}
      quality={80}
      format="webp"
      alt="Optimized Image"
    />
  </div>
);

export default App;

Props

| Prop | Type | Required | Description | | ----------- | ------------------------------- | -------- | ------------------------------------------------------------ | | src | string | Yes | The source URL of the image. | | width | number | No | Desired width of the image. | | height | number | No | Desired height of the image. | | quality | number (0-100) | No | Quality of the image (default is 100). | | format | 'webp', 'jpeg', 'png', 'avif' | No | Image format (e.g., webp, jpeg, png, avif). | | alt | string | No | Alternative text for the image (default is an empty string). | | className | string | No | Additional CSS classes for styling the image. |

Configuring the Base URL

The base URL is used for resolving relative image paths and is configured globally. This means once you set it using StaticDelivr.set(), it will apply across your entire application unless changed.

StaticDelivr.set({ baseURL: 'https://example.com/images/' });

This configuration is especially useful when working with relative URLs. If a relative path is provided in the src prop, it will be automatically resolved using the global baseURL. If you pass an absolute URL to the src prop, the base URL will not be applied.

Example: Configuring in a Global Application File

You can configure the base URL globally in a file like _app.tsx in a Next.js application:

// pages/_app.tsx
import React from 'react';
import { StaticDelivr } from 'staticdelivr';

StaticDelivr.set({ baseURL: 'https://example.com/images/' });

const MyApp = ({ Component, pageProps }) => <Component {...pageProps} />;

export default MyApp;

Example: Absolute URLs

<StaticDelivrImage
  src="https://other-cdn.com/image.jpg"
  width={400}
  height={300}
  quality={90}
  format="jpeg"
  alt="External Image"
/>

Example: Relative URLs

<StaticDelivrImage
  src="/path/to/image.jpg"
  width={500}
  height={400}
  quality={70}
  format="png"
  alt="Local Image"
/>

Easy Integration

StaticDelivr is designed to be straightforward to integrate into your application. You can directly replace your existing <img> tags or components like the Next.js <Image> tag with StaticDelivrImage, making it a seamless transition for projects looking to optimize image delivery.

For example, in a Next.js application, if your images are stored in the public directory, they are typically accessed as:

<img src="/images/photo.jpg" alt="Example" />

By using StaticDelivrImage and configuring the baseURL to your website's domain, you can optimize these images effortlessly:

StaticDelivr.set({ baseURL: 'https://example.com' });

<StaticDelivrImage
  src="/images/photo.jpg"
  width={800}
  height={600}
  quality={85}
  format="webp"
  alt="Example"
/>

Here, the baseURL ensures that relative paths (e.g., /images/photo.jpg) are resolved to https://example.com/images/photo.jpg, streamlining image optimization and delivery.

Development

Running Tests

To run the test suite:

npm test

Linting

Ensure code quality by running:

npm run lint

Building the Package

Build the library for distribution:

npm run build

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

StaticDelivr is inspired by the need for efficient and reliable image delivery solutions. Special thanks to all the contributors at StaticDelivr.