Skip to main content

Filebase npm package

The @filebase/sdk npm package is a thin convenience wrapper around the AWS SDK for JavaScript with Filebase defaults pre-configured. It's optional — you can use the AWS SDK directly with the same config — but if you want to skip the boilerplate, it's a one-liner.

Install

npm install @filebase/sdk

Initialize

import { ObjectManager } from '@filebase/sdk';

const objectManager = new ObjectManager(
process.env.FILEBASE_KEY,
process.env.FILEBASE_SECRET,
{ bucket: 'my-bucket' },
);

The endpoint and region are pre-set to https://s3.filebase.io and auto.

Upload an object

import { readFile } from 'node:fs/promises';

const body = await readFile('photo.jpg');

const result = await objectManager.upload('photo.jpg', body, {
contentType: 'image/jpeg',
});

console.log(result);

Download an object

const data = await objectManager.download('photo.jpg');

List objects

const result = await objectManager.list();
console.log(result.results);

Delete an object

await objectManager.delete('photo.jpg');

When to use the wrapper vs. the AWS SDK directly

Use this package when:

  • You want minimal boilerplate.
  • Your code is Filebase-specific and doesn't need to work against other S3 providers.

Use the AWS SDK for JavaScript directly when:

  • You want the full S3 API surface (multipart upload helpers, pre-signed URLs, custom retries, etc.).
  • You're already writing AWS SDK code or want to swap providers later.

What's next