vs3

Adapters

Connect vs3 to any S3-compatible storage provider.

Adapters provide a preconfigured S3 client for your storage provider. Every adapter uses the official AWS S3 SDK (@aws-sdk/client-s3) under the hood — the only difference between adapters is how the client is configured (endpoint, region, credentials, etc.). We currently provide support for the following adapters:

If you cannot find an adapter for your provider, you can always create your own adapter by following the custom adapters section.

Pass an adapter to createStorage to connect vs3 to your provider:

import { createStorage } from "vs3";
import { aws } from "vs3/adapters";

const storage = createStorage({
  bucket: "my-bucket",
  adapter: aws({
    region: "us-east-1",
    credentials: {
      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
    },
  }),
});

All adapters require the @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner peer dependencies to be installed.


AWS S3

The aws adapter connects to Amazon S3. It accepts the same options as the AWS SDK S3Client constructor.

import { aws } from "vs3/adapters";

const adapter = aws({
  region: "us-east-1",
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
  },
});
OptionTypeRequiredDescription
regionstringYesAWS region (e.g. us-east-1).
credentialsobjectYesaccessKeyId and secretAccessKey.

Any additional S3ClientConfig options are forwarded to the underlying client.


Cloudflare R2

The cloudflareR2 adapter configures the S3 client for Cloudflare R2 with the correct endpoint and region.

import { cloudflareR2 } from "vs3/adapters";

const adapter = cloudflareR2({
  accountId: process.env.CF_ACCOUNT_ID!,
  credentials: {
    accessKeyId: process.env.R2_ACCESS_KEY_ID!,
    secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
  },
});
OptionTypeRequiredDescription
accountIdstringYesYour Cloudflare account ID.
credentialsobjectYesaccessKeyId and secretAccessKey.
jurisdiction"eu" | "fedramp"NoData locality jurisdiction.

MinIO

The minio adapter configures the S3 client with path-style access, which is required by MinIO.

import { minio } from "vs3/adapters";

const adapter = minio({
  endpoint: "http://localhost:9000",
  credentials: {
    accessKeyId: process.env.MINIO_ACCESS_KEY!,
    secretAccessKey: process.env.MINIO_SECRET_KEY!,
  },
});
OptionTypeRequiredDescription
endpointstringYesFull URL to your MinIO instance.
credentialsobjectYesaccessKeyId and secretAccessKey.
regionstringNoDefaults to us-east-1.

Backblaze B2

The backblazeB2 adapter configures the S3-compatible endpoint for Backblaze B2.

import { backblazeB2 } from "vs3/adapters";

const adapter = backblazeB2({
  region: "us-west-000",
  credentials: {
    accessKeyId: process.env.B2_ACCESS_KEY_ID!,
    secretAccessKey: process.env.B2_SECRET_ACCESS_KEY!,
  },
});
OptionTypeRequiredDescription
regionstringYesB2 region (e.g. us-west-000, eu-central-003).
credentialsobjectYesaccessKeyId and secretAccessKey.

DigitalOcean Spaces

The digitaloceanSpaces adapter configures the S3 client for DigitalOcean Spaces.

import { digitaloceanSpaces } from "vs3/adapters";

const adapter = digitaloceanSpaces({
  region: "nyc3",
  credentials: {
    accessKeyId: process.env.DO_SPACES_KEY!,
    secretAccessKey: process.env.DO_SPACES_SECRET!,
  },
});
OptionTypeRequiredDescription
regionstringYesDatacenter region (e.g. nyc3, ams3, sgp1).
credentialsobjectYesaccessKeyId and secretAccessKey.

Wasabi

The wasabi adapter configures the S3 client for Wasabi Hot Cloud Storage.

import { wasabi } from "vs3/adapters";

const adapter = wasabi({
  region: "us-east-1",
  credentials: {
    accessKeyId: process.env.WASABI_ACCESS_KEY!,
    secretAccessKey: process.env.WASABI_SECRET_KEY!,
  },
});
OptionTypeRequiredDescription
regionstringYesWasabi region (e.g. us-east-1, eu-central-1).
credentialsobjectYesaccessKeyId and secretAccessKey.

Custom Adapter

If your provider is not listed above, use createAdapter to wrap any existing S3Client instance:

import { S3Client } from "@aws-sdk/client-s3";
import { createAdapter } from "vs3/adapters";

const client = new S3Client({
  endpoint: "https://s3.custom-provider.com",
  region: "us-east-1",
  credentials: {
    accessKeyId: process.env.S3_ACCESS_KEY!,
    secretAccessKey: process.env.S3_SECRET_KEY!,
  },
});

const adapter = createAdapter({ client });

This gives you full control over the S3 client configuration while still integrating with vs3.

On this page