Node.js
There are two ways to use Tigris with Node.js:
- Tigris SDK — a type-safe SDK for TypeScript and JavaScript with a simple, high-level API. This is the recommended approach.
- AWS JavaScript SDK — use the standard AWS SDK for JavaScript v3, just point it at Tigris. Useful if you have existing AWS S3 code to migrate.
Both are fully S3-compatible. We recommend the Tigris SDK for new projects.
Prerequisites
- Node.js 18+
- A Tigris account — create one at storage.new
- An access key from console.storage.dev/createaccesskey
Install
- Tigris SDK
- AWS JS SDK
npm install @tigrisdata/storage
npm install @aws-sdk/client-s3
Configure credentials
Set your Tigris credentials as environment variables:
- Tigris SDK
- AWS JS SDK
export TIGRIS_STORAGE_ACCESS_KEY_ID="tid_your_access_key"
export TIGRIS_STORAGE_SECRET_ACCESS_KEY="tsec_your_secret_key"
export TIGRIS_STORAGE_BUCKET="my-bucket"
Or add them to a .env file in your project root:
TIGRIS_STORAGE_ACCESS_KEY_ID=tid_your_access_key
TIGRIS_STORAGE_SECRET_ACCESS_KEY=tsec_your_secret_key
TIGRIS_STORAGE_BUCKET=my-bucket
export AWS_ACCESS_KEY_ID="tid_your_access_key"
export AWS_SECRET_ACCESS_KEY="tsec_your_secret_key"
export AWS_ENDPOINT_URL="https://t3.storage.dev"
export AWS_REGION="auto"
Create a client
- Tigris SDK
- AWS JS SDK
The Tigris SDK reads credentials from environment variables automatically — no client setup needed:
import { list, put, get } from "@tigrisdata/storage";
import { S3Client } from "@aws-sdk/client-s3";
const s3 = new S3Client({
region: "auto",
endpoint: "https://t3.storage.dev",
});
If you set AWS_ENDPOINT_URL in your environment, you can omit the endpoint
option.
Basic operations
- Tigris SDK
- AWS JS SDK
Upload an object
import { put } from "@tigrisdata/storage";
await put("hello.txt", "Hello, World!");
// Upload a file from disk
import { readFileSync } from "fs";
await put("data.csv", readFileSync("data.csv"));
Download an object
import { get } from "@tigrisdata/storage";
const data = await get("hello.txt");
console.log(data.toString());
List objects
import { list } from "@tigrisdata/storage";
const objects = await list();
console.log(objects);
Delete an object
import { del } from "@tigrisdata/storage";
await del("hello.txt");
Upload an object
import { PutObjectCommand } from "@aws-sdk/client-s3";
await s3.send(
new PutObjectCommand({
Bucket: "my-bucket",
Key: "hello.txt",
Body: "Hello, World!",
}),
);
Download an object
import { GetObjectCommand } from "@aws-sdk/client-s3";
const result = await s3.send(
new GetObjectCommand({
Bucket: "my-bucket",
Key: "hello.txt",
}),
);
const body = await result.Body.transformToString();
console.log(body);
List objects
import { ListObjectsV2Command } from "@aws-sdk/client-s3";
const result = await s3.send(new ListObjectsV2Command({ Bucket: "my-bucket" }));
for (const obj of result.Contents ?? []) {
console.log(` ${obj.Key} (${obj.Size} bytes)`);
}
Generate a presigned URL
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { GetObjectCommand } from "@aws-sdk/client-s3";
const url = await getSignedUrl(
s3,
new GetObjectCommand({ Bucket: "my-bucket", Key: "hello.txt" }),
{ expiresIn: 3600 },
);
console.log(url);
Next steps
- Example Next.js app — a Next.js app that uploads and manages files with the Tigris SDK, ready to deploy to Vercel
- Tigris SDK reference — full SDK documentation including client uploads, multipart uploads, and more
- AWS JS SDK reference — advanced usage with presigned URLs, metadata queries, and conditional operations