core icon indicating copy to clipboard operation
core copied to clipboard

Can’t Bind Additional R2 Buckets in NuxtHub

Open Alecyrus opened this issue 5 months ago • 3 comments

Describe the bug When trying to add an extra R2 binding in NuxtHub using the following configuration:

// nuxt.config.ts
hub: {
  ai: true,
  database: true,
  kv: true,
  blob: true,
  cache: true,
  workers: true,
  bindings: {
    // @ts-ignore
    r2_bucket: {
      RAG_STORE: {
        bucket_name: "test-rag-store",
      },
    },
  },
}

the binding does not take effect. When I print event.context.cloudflare.env, the output is always:

{ CACHE: ProxyStub { name: 'KvNamespace', poisoned: false } }

No R2 bucket appears in the environment.

Steps to reproduce

  1. Add the above configuration to your NuxtHub setup.
  2. Deploy and log event.context.cloudflare.env.
  3. Observe that only CACHE is present, with no R2 bindings.

Expected behavior I expect the R2 bucket (RAG_STORE) to show up in event.context.cloudflare.env, allowing direct access to the bound R2 store.

Additional context

  • Using the latest NuxtHub core version.
  • Other bindings (KV, cache) work as expected.
  • No errors during deployment, but R2 is missing from the environment.

Alecyrus avatar Sep 02 '25 23:09 Alecyrus

Just to add a bit more context—

Image

The docs mention that it's possible to add extra R2 bucket bindings, but when I try to set r2_bucket in hub.bindings in my nuxt.config.ts, I get a TypeScript error. Also, it's not really clear in the docs how to actually access these R2 bucket bindings from a server handler.

Could you clarify the correct way to set this up, and maybe provide an example of how to use the R2 bucket binding in a handler? I haven't been able to find a working configuration, so any guidance would be appreciated. Thanks!

Alecyrus avatar Sep 03 '25 00:09 Alecyrus

Hello, I am also facing this. I want to add a new binding and thought it would be something like this:

hub: {
  bindings: {
      r2_bucket: {
        RESOURCES_BUCKET: 'docuyond-app-resources',
      },
    },
}

But now I don't know if it is correct or how can I use it from my server endpoint, since before I just used await hubBlob().put, but not not sure what to call...

raress96 avatar Sep 14 '25 17:09 raress96

Any updates on how we can use two or more R2 buckets?

raress96 avatar Oct 13 '25 07:10 raress96

With NuxtHub v0.10 we now support multi-cloud and therefore NuxtHub Admin is being deprecated. With that, you can now deploy directly on your Cloudflare account using Wrangler so you can add the additional R2 bindings within the generated wrangler.jsonc file from our migration tool. https://hub.nuxt.com/changelog/nuxthub-multi-vendor#nuxthub-admin-transition

RihanArfan avatar Dec 10 '25 16:12 RihanArfan