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

payload-cloudflare-images-storage-adapter

v0.0.1

Published

A Payload CMS storage adapter for Cloudflare Images

Readme

Payload Cloudflare Images Storage Adapter (@payloadcms/storage-cloudflare-images)

GitHub Repo

A storage adapter for Payload CMS that enables uploading media directly to Cloudflare Images.

Installation

# pnpm
pnpm add @payloadcms/storage-cloudflare-images @payloadcms/plugin-cloud-storage

# npm
npm install @payloadcms/storage-cloudflare-images @payloadcms/plugin-cloud-storage

# yarn
yarn add @payloadcms/storage-cloudflare-images @payloadcms/plugin-cloud-storage

Prerequisites

  • A Cloudflare Account with Cloudflare Images enabled.
  • Your Cloudflare API Key.
  • Your Cloudflare Account ID.
  • Your Cloudflare Images Account Hash.

These credentials should be stored securely, typically as environment variables.

Usage

In your payload.config.ts, import the cloudStoragePlugin and the cloudflareImagesAdapter:

// payload.config.ts
import { buildConfig } from 'payload/config';
import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
import { cloudflareImagesAdapter } from '@payloadcms/storage-cloudflare-images'; // Assuming it's installed
import { Media } from './collections/Media'; // Your media collection slug

// Ensure environment variables are set and valid
const cfApiKey = process.env.CLOUDFLARE_API_KEY;
const cfAccountId = process.env.CLOUDFLARE_ACCOUNT_ID;
const cfAccountHash = process.env.CLOUDFLARE_ACCOUNT_HASH;

if (!cfApiKey || !cfAccountId || !cfAccountHash) {
  // Handle missing credentials appropriately - throw error in production
  console.error('Missing Cloudflare credentials!');
  // throw new Error('Missing Cloudflare credentials');
}

export default buildConfig({
  collections: [
    // Your other collections
    Media,
  ],
  plugins: [
    cloudStoragePlugin({
      collections: {
        [Media.slug]: {
          // Your media collection slug
          adapter: cloudflareImagesAdapter({
            apiKey: cfApiKey!,
            accountId: cfAccountId!,
            accountHash: cfAccountHash!,
            // variant: 'public', // Optional: specify default variant
          }),
          // Disable Payload's default access control and static route handler
          // This allows URLs to point directly to Cloudflare's CDN
          disablePayloadAccessControl: true,
        },
      },
    }),
    // Your other plugins
  ],
  // ... rest of your config
});

Configuration Options

The cloudflareImagesAdapter function accepts an object with the following properties:

| Option | Type | Required | Description | Default | | ------------- | -------- | -------- | ------------------------------------------------------------------- | ---------- | | apiKey | string | Yes | Your Cloudflare API Key. | | | accountId | string | Yes | Your Cloudflare Account ID (used for API calls). | | | accountHash | string | Yes | Your Cloudflare Images Account Hash (used for delivery URLs). | | | variant | string | No | The default Cloudflare Image variant name to use in generated URLs. | 'public' |

Important Notes

  • Added Field: This adapter automatically adds a read-only text field named cloudflareId to your specified media collection(s). This field stores the ID returned by Cloudflare upon successful upload and is used for generating URLs and handling deletes.
  • disablePayloadAccessControl: true: Setting this option (recommended for CDN usage) means:
    • The URLs generated for your media will point directly to imagedelivery.net.
    • Payload's built-in read access control for the media collection will not apply to accessing the files via their URL. Access control must be managed within Cloudflare Images (e.g., using Signed URLs if needed, though this adapter doesn't support generating them currently).
    • Payload's static handler is bypassed for these files.
  • Environment Variables: Ensure the following environment variables are set in your deployment environment:
    • CLOUDFLARE_API_KEY
    • CLOUDFLARE_ACCOUNT_ID
    • CLOUDFLARE_ACCOUNT_HASH

License

MIT