B2 storage
Add a Backblaze B2 file bucket to your project.
npx extraorbital add b2Free-plan files are hidden after 30 days and deleted 10 days later.
- 01 / Run the commandGet the service
- 02 / Read your .envUse its credentials
- 03 / Connect your appCall the SDK or API
Limits
| Limit | Free · Prototype | Paid |
|---|---|---|
| Storage | Your allowance | Usage billed |
| Requests | Free | Free |
| Bandwidth | 3× storage, then $0.01 / GB | 3× storage, then $0.01 / GB |
| File retention | Hidden 30 days after upload, deleted 10 days later | Kept until you delete it |
| Backups | None | Charged as storage |
| Inactive resource | 30 days after last use | Persistent |
Free allowances are shared across the account. Provider limits still apply on paid plans.
Use it
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
const b2 = new S3Client({
region: process.env.B2_REGION,
endpoint: process.env.B2_ENDPOINT,
forcePathStyle: true,
credentials: {
accessKeyId: process.env.B2_ACCESS_KEY_ID!,
secretAccessKey: process.env.B2_SECRET_ACCESS_KEY!,
},
});
await b2.send(
new PutObjectCommand({ Bucket: process.env.B2_BUCKET, Key: "report.json", Body: data }),
);Environment variables
The CLI writes these to .env or an existing .env.local.
| Variable | Purpose |
|---|---|
B2_BUCKET | Bucket name |
B2_ENDPOINT | S3-compatible endpoint |
B2_REGION | Region determined by the provider account |
B2_ACCESS_KEY_ID | Bucket access key |
B2_SECRET_ACCESS_KEY | Private signing secret |
Specifics
Options
npx extraorbital add b2 [--slug <name>] [--public]| Flag | Default | Description |
|---|---|---|
--slug | default | A second, fully separate bucket in the same project |
--public | off | Objects are publicly readable |
The account determines the region. B2_REGION reports it; there is no region option.
Options apply at creation. Reusing a slug does not change the bucket. Use a new slug for a different configuration.
Access
Credentials are limited to this bucket. --public makes objects readable without authentication. Use a new slug for a different configuration; repeating add reuses the existing bucket.
File retention
Free-plan files are hidden 30 days after upload, then deleted 10 days later by a Backblaze lifecycle rule.
Hidden files cannot be read or listed. Upgrading during the 10-day window restores access; deleted files cannot be restored.
Upgrading removes future expiry within an hour.
The supplied key manages objects, not bucket configuration. You cannot change the lifecycle rule.
File expiry applies even when a bucket is active. The separate inactivity policy deletes resources unused for 30 days.
Pricing
| Usage | Paid rate |
|---|---|
| Storage | $0.00695 / GB-mo |
| Requests | Free |
| Bandwidth | 3× storage, then $0.01 / GB |
See pricing for team subscription fees, allowances, and billing terms. Plans and billing ↗
Storage is sampled daily. Egress is tracked at account level, not per bucket. Usage appears after each UTC day closes.