@upstash/blob is the TypeScript SDK. It has a Bucket client and an upload handler for your server, and the browser client that uploads from the browser straight to storage.
This section is the TypeScript reference: names, types, and framework wiring. What each call does, its defaults and its limits are on the concept pages it links to.
Install
node_modules/@upstash/blob/docs/.
Entrypoints
/browser and /react are the browser client. They talk to an upload route over HTTP, so the route behind them can be written with any server SDK.
The Bucket client
lib/blob.ts
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:
There is no visibility option. Whether the bucket is public or private is a console setting; see Connecting.
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:.
Retries
Which requests are retried, and the default budget and backoff, are on Retries.
Using an S3 client
bucket.s3() returns a config for @aws-sdk/client-s3. 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.
What an S3 client is for, and why it must not presign, is on Using an S3 client.
Option types
All three are exported as types from
@upstash/blob.
A limit you write by hand takes a Size: maxSize, multipart. A measurement you forward is a plain number of bytes: the size option on put, and every size the SDK returns. That mirrors File.size and Blob.size, so a value flows from one to the other without conversion.
Next steps
Bucket API
Every
Bucket method, its options and the records it returns.Upload handler
uploadHandler options, callbacks, and mounting it in Next.js, Hono and more.Errors
BlobError, BlobError.is(), and the fields an error carries.Browser client
useUpload, useServerUpload and the non-React upload().