Skip to content

templates/with-cloudflare-d1: storage config key doesn't exist in released 3.x — R2 never applied and admin crashes with "Functions cannot be passed directly to Client Components" #17195

Closed

Description

@Tseku210

Describe the Bug

The with-cloudflare-d1 template on main registers the R2 storage adapter through a storage key in src/payload.config.ts:

https://github.com/payloadcms/payload/blob/main/templates/with-cloudflare-d1/src/payload.config.ts

storage: [
  r2Storage({
    bucket: cloudflare.env.R2,
    collections: { media: true },
  }),
],

That config key does not exist in released Payload 3.x. I verified against [email protected]: there is no reference to a storage key anywhere in the config build/sanitize code under node_modules/payload/dist. It appears to be an unreleased API that only exists on main, while the template's package.json pins released 3.x versions — so anyone scaffolding the template today gets a broken combination.

Three consequences on released versions:

  1. r2Storage is silently never applied. Uploads fall back to local disk storage, which breaks on Cloudflare Workers (no writable filesystem).
  2. The admin panel crashes entirely. The unknown storage key (containing plugin functions) is passed through to the client config, and every admin page — including /admin/login and /admin/create-first-user — dies with:
    Error: Functions cannot be passed directly to Client Components
    
    (observed digest: 4235013658)
  3. payload generate:importmap omits R2ClientUploadHandler, since the plugin is never registered.

Workaround / suggested fix

Registering the adapter via plugins instead fixes all three:

   db: sqliteD1Adapter({ binding: cloudflare.env.D1 }),
   logger: isProduction ? cloudflareLogger : undefined,
-  storage: [
+  plugins: [
     r2Storage({
       bucket: cloudflare.env.R2,
       collections: { media: true },
     }),
   ],

After this change the admin panel loads, R2 uploads work on Workers, and payload generate:importmap emits R2ClientUploadHandler as expected.

Suggestion: either switch the template to plugins: [], or pin the template's dependencies to a Payload version where the storage config key actually exists.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/templates/with-cloudflare-d1

(The unmodified template is the reproduction — no extra code needed.)

Reproduction Steps

  1. npx degit payloadcms/payload/templates/with-cloudflare-d1 repro && cd repro
  2. pnpm install
  3. pnpm dev
  4. Open http://localhost:3000/admin
  5. Every admin route (login, create-first-user) crashes with Functions cannot be passed directly to Client Components.
  6. Additionally note that pnpm payload generate:importmap produces an import map without R2ClientUploadHandler, and no R2 upload handling is wired up.

Which area(s) are affected?

area: templates, plugin: storage-*, db: d1-sqlite

Environment Info

payload: 3.82.1 (as pinned by the template; `storage` key also verified absent in 3.85.2)
@payloadcms/db-d1-sqlite: 3.82.1
@payloadcms/storage-r2: 3.82.1
@payloadcms/next: 3.82.1
next: 15.4.11 (template default)
node: v26.3.1
pnpm: 10.33.0
OS: macOS (darwin 25.5.0)

Activity

  1. added
    area: templates
    db: d1-sqlite
    on Jul 3, 2026
  2. nathanlentz commented on Aug 3, 2026

    @nathanlentz
    Collaborator

    We are now pointing the One Click deployment button to Cloudflare to 3.x (17612) until v4 releases which correctly uses plugins for the pinned Payload version in that template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: templatesdb: d1-sqliteplugin: storage-*

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions