Bucket client, the options it takes, and running it on platforms without process.env.
lib/blob.ts
.env
NEXT_PUBLIC_, VITE_, or any other variable your bundler inlines into client code.
Options
lib/blob.ts
Bucket.fromEnv() is the same constructor with token read from UPSTASH_BLOB_TOKEN. It takes the same options minus the token, and a variable name when the token lives somewhere else:
Whether the bucket is public or private is a console setting, not an option: the SDK learns it from the backend on the first request. See Private buckets.
Constructing a
Bucket per request is fine. Credentials are cached per token, so two clients built from the same token share one.
Cloudflare Workers
There is noprocess.env on Workers, so Bucket.fromEnv() throws. Pass the token from the request’s env:
src/index.ts
env and pass it as bucket:.
Telemetry
The SDK sends its version, runtime and platform as headers on credential requests to Upstash. Turn it off withUPSTASH_DISABLE_TELEMETRY in the environment (any value), or enableTelemetry: false on the Bucket.
Using an S3 client
bucket.s3() returns a config for @aws-sdk/client-s3, for anything the SDK does not wrap: byte ranges, conditional GETs, delimiters and common prefixes, object tagging.
endpoint and credentials are async providers rather than values. Pass them through as they come, so the aws-sdk can pick up a fresh credential when the old one expires.
An error message that mentions R2 is talking about the storage layer.
Next steps
Writing
put, metadata, conditional writes and multipart from the server.Reading
get, info, exists, list and signed read URLs.