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

payloadcms-storage-cloudflare

v1.0.0

Published

Cloudflare Storage adapter for PayloadCMS

Readme

PayloadCMS Storage Adapter for Cloudflare

A storage adapter for PayloadCMS that enables storing media files on Cloudflare Images and Cloudflare Stream.

Installation

npm install payloadcms-storage-cloudflare
# or
yarn add payloadcms-storage-cloudflare
# or
pnpm add payloadcms-storage-cloudflare

Requirements

  • PayloadCMS v3.0.0 or higher
  • Cloudflare account with Images and/or Stream enabled
  • Cloudflare API token with appropriate permissions

Usage

Add the plugin to your Payload config:

import { buildConfig } from 'payload/config';
import { cloudflareStorage } from 'payloadcms-storage-cloudflare';

export default buildConfig({
  // ... other config
  plugins: [
    cloudflareStorage({
      collections: {
        media: true, // Enable for the Media collection
      },
      config: {
        accountId: env.CLOUDFLARE_ACCOUNT_ID, // Found in the sidebar of your Cloudflare Stream/Image dashboard
        apiToken: env.CLOUDFLARE_API_TOKEN, // Found under your Cloudflare account API tokens
        customerSubdomain: env.CLOUDFLARE_CUSTOMER_SUBDOMAIN, // Found in the sidebar of your Cloudflare Stream dashboard
        imageDeliveryUrl: env.CLOUDFLARE_IMAGE_DELIVERY_URL, // Found in the sidebar of your Cloudflare Image dashboard
      },
    }),
  ],
});

Client Uploads

This adapter supports client-side uploads, which allow files to be uploaded directly from the browser to Cloudflare, bypassing your server entirely. This is especially useful for large video files or when deploying to environments with upload size limitations (like Vercel).

To enable client uploads:

import { buildConfig } from 'payload/config';
import { cloudflareStorage } from 'payloadcms-storage-cloudflare';

export default buildConfig({
  // ... other config
  plugins: [
    cloudflareStorage({
      collections: {
        media: true, // Enable for the Media collection
      },
      config: {
        accountId: env.CLOUDFLARE_ACCOUNT_ID,
        apiToken: env.CLOUDFLARE_API_TOKEN,
        customerSubdomain: env.CLOUDFLARE_CUSTOMER_SUBDOMAIN,
        imageDeliveryUrl: env.CLOUDFLARE_IMAGE_DELIVERY_URL,
      },
      // Enable client uploads with default settings
      clientUploads: true,
      
      // Or use custom access control
      // clientUploads: {
      //   access: ({ req, collectionSlug }) => {
      //     // Custom access control logic
      //     return !!req.user;
      //   }
      // }
    }),
  ],
});

How Client Uploads Work

  1. When a user uploads a file in the admin UI, the file is intercepted by the client handler
  2. The client requests secure upload URLs from your server (which validates the request)
  3. The file is uploaded directly from the browser to Cloudflare
  4. Only metadata about the file is sent to your server for storage in the database
  5. Your server never handles the actual file data

This approach improves upload performance and works around server upload size limitations.

Configuration Options

Plugin Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | collections | Record<string, boolean \| object> | Yes | Collections to enable the adapter for | | enabled | boolean | No | Whether the plugin is enabled (default: true) | | config | object | Yes | Cloudflare configuration | | clientUploads | boolean \| object | No | Enable client-side uploads (default: false) |

Cloudflare Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | accountId | string | Yes | Your Cloudflare account ID | | apiToken | string | Yes | Your Cloudflare API token | | customerSubdomain | string | No* | Your Cloudflare Stream subdomain | | accountHash | string | No* | Your Cloudflare Images account hash |

* Either customerSubdomain or accountHash is required depending on your use case.

Features

  • Upload files to Cloudflare Images and Stream
  • Automatic detection of file types (images vs videos)
  • Client-side uploads for improved performance
  • Supports large file uploads using TUS protocol
  • Proper URL generation for different media types
  • Handles file deletion

License

MIT