session.blob stores arbitrary bytes (PDFs, EPUBs, audio, video, model files, caches) as files on the phone. It’s scoped to the user and your miniapp, so your keys never collide with another miniapp’s, and the files survive restarts. Where session.storage holds small strings, blob holds binary data.
src/background/index.ts
Blob needs no permission and no hardware. Every method is async and round-trips to the phone. A stored blob’s uri is a file:// path in your miniapp’s private storage, which you can hand to session.speaker.play, session.blob.share, or another host capability.

Reading and writing

set takes a Uint8Array, an ArrayBuffer, or a base64 string, and returns the stored blob’s metadata. get returns that metadata (including the uri) or null. bytes reads the whole file into memory.
bytes throws once a blob crosses BLOB_READ_ALL_MAX_BYTES (32 MB). Read anything larger as a stream.

Downloading and importing without crossing the bridge

setFromUrl downloads a URL straight to disk host-side, and importFile opens the OS file picker and stores the chosen file. In both cases the bytes never pass through your JS context, which keeps large files off the bridge.

Usage and quota

usage reports how much you’ve stored and the quota ceiling, all in bytes.

Large files: streaming

For files past the in-memory caps, stream them. createWriteStream opens a BlobWriter: call write or writeBase64 as many times as you need (each call auto-splits into bridge-safe chunks of BLOB_WRITE_CHUNK_BYTES, 1 MB raw), then close to publish or abort to discard the partial blob.
createReadStream opens a BlobReader. Call read for the next chunk until done is true, then close.

BlobWriter

BlobReader

Method reference

BlobMeta

get, stat, list, and close resolve to a BlobMeta.

Size limits

Errors

For small strings (counters, flags, serialized settings), use session.storage instead. To share or export a file you didn’t store as a blob, see session.system.