Storage
S3-compatible object storage
Buckets, signed URLs, automatic image optimization and a global CDN — all from the SDK.
Create a bucket
typescript
await nb.storage.createBucket("avatars", {
public: false,
fileSizeLimit: "5MB",
allowedMimeTypes: ["image/png", "image/jpeg", "image/webp"],
});Upload a file
typescript
const file = input.files![0];
const { data, error } = await nb.storage
.from("avatars")
.upload(`user/${userId}/avatar.png`, file, {
upsert: true,
cacheControl: "31536000",
});Download / signed URL
typescript
// Public bucket
const url = nb.storage.from("public").getPublicUrl("hero.jpg").data.publicUrl;
// Private bucket – signed URL (10 minutes)
const { data } = await nb.storage
.from("avatars")
.createSignedUrl(`user/${userId}/avatar.png`, 600);Image transformations
typescript
nb.storage.from("avatars").getPublicUrl("me.png", {
transform: { width: 200, height: 200, resize: "cover", quality: 80, format: "webp" },
});Delete
typescript
await nb.storage.from("avatars").remove(["user/1/avatar.png", "user/2/avatar.png"]);