Skip to content

Reference — /s3

import { S3ObjectStore } from 'git-fs-s3/s3';

Node.jsCloudflare WorkersDenoBrowser

new S3ObjectStore(options: S3ObjectStoreOptions)
ParameterTypeDescription
options.clientS3ClientA configured client — works with AWS S3, Cloudflare R2, MinIO, Backblaze B2.
options.bucketstring
options.prefix?stringKey prefix for every object.
options.contentType?(key: string) => string | undefinedDerives a Content-Type for uploads. Cosmetic only — git never reads it back.

Implements ObjectStore (see the guide) over any S3-compatible API.

import { S3Client } from '@aws-sdk/client-s3';
import { S3ObjectStore } from 'git-fs-s3/s3';
const store = new S3ObjectStore({
client: new S3Client({
region: 'auto',
endpoint: process.env.R2_ENDPOINT, // omit for AWS S3
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
}),
bucket: 'my-git-repos',
contentType: (key) =>
/\/(HEAD|config)$|\/refs\//.test(key) ? 'text/plain' : undefined,
});

@aws-sdk/client-s3 is an optional peer dependency, loaded only when you import this subpath — the root package and /http//ops never pull it in.