---
title: "AWS SDK for JavaScript (v3) With Wasabi"
slug: "how-do-i-use-aws-sdk-for-javascript-v3-with-wasabi"
updated: 2025-07-03T14:08:30Z
published: 2025-07-03T14:08:30Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wasabi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS SDK for JavaScript (v3) With Wasabi

[AWS SDK for JavaScript (v3)](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/) has been certified for use with Wasabi. Wasabi uses this SDK to help power the [Wasabi Management Console](https://console.wasabisys.com/) .

The user will need to install the node package based on the Operating System from the link [here](https://nodejs.org/en/download/current) .

Verification of node installation:

```powershell
Command: node -v
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/18225918075419.png)

Users can now use a separate package for each service known as [Modularized packages](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html) . Run the below command to install AWS SDK for JavaScript:

```powershell
npm install @aws-sdk/client-service
```

Examples to install IAM, S3 and credentials-provider module in AWS SDK for JavaScript (v3) are below and visit for others [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/introduction/) :

```powershell
npm install @aws-sdk/client-iam
```

```powershell
npm install @aws-sdk/client-s3
```

```powershell
npm install @aws-sdk/credential-provider-ini
```

Output Screenshots of the installations:

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/18225895262875.png)

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/18225826466587.png)

Output from package.json after upgrading to AWS SDK for JavaScript (v3):

```powershell
{
"dependencies": {
"@aws-sdk/client-iam": "^3.395.0",
"@aws-sdk/client-s3": "^3.397.0",
"@aws-sdk/credential-provider-ini": "^3.395.0"
}
}
```

#### To use the Javascript SDK execute the following steps:

1) Install the [AWS SDK for Javascript using npm](https://aws.amazon.com/sdk-for-javascript/)

2) Configure additional [AWS CLI profile for Wasabi](/v1/docs/how-do-i-use-aws-cli-with-wasabi) account using the Wasabi keys (optional)

In this example, we have set the profile name as "wasabi" in the "~/.aws/credentials" file. To help our customers use this SDK with Wasabi, we have provided examples for both IAM and S3. This example shows:

Other examples can be referred from the [AWS documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/).

*Note that this example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this*[*article*](/v1/docs/what-are-the-service-urls-for-wasabis-different-storage-regions)*.*

*Please send all IAM requests to iam.wasabisys.com*

## 1. How to set the credentials.

```powershell
// Load the SDK
const { S3Client } = require("@aws-sdk/client-s3");
const { IAMClient } = require("@aws-sdk/client-iam");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials
const credentials = fromIni({ profile: "wasabi" });
const iam = new IAMClient({ credentials }); // for IAM
const s3 = new S3Client({ credentials }); // for S3

// Set the AWS region. us-east-1 is the default for IAM calls.
const region = "us-east-1";
const iam = new IAMClient({ region: region }); // for IAM
const s3 = new S3Client({ region: region }); // for S3
```

## 2. Connect to IAM and S3 endpoints

IAM:

```powershell
// Load the SDK
const { IAMClient } = require("@aws-sdk/client-iam");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for IAM
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // us-east-1 is the default for IAM calls
const endpoint = "https://iam.wasabisys.com";

// Create an IAM client
const iam = new IAMClient({ credentials, region, endpoint });
```

S3:

```powershell
// Load the SDK
const { S3Client } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for S3
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // replace with your S3 bucket region
const endpoint = "https://s3.us-east-1.wasabisys.com"; // replace with your S3 bucket service URL

// Create an S3 client
const s3 = new S3Client({ credentials, region, endpoint });
```

## 3. Create a user using IAM

```powershell
const { IAMClient, CreateUserCommand } = require("@aws-sdk/client-iam");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for IAM
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // us-east-1 is the default for IAM calls
const endpoint = "https://iam.wasabisys.com";

// Create an IAM client
const iam = new IAMClient({ credentials, region, endpoint });

const params = {
UserName: "NewUser" //replace with your IAM username here
};

const createUserCommand = new CreateUserCommand(params);

iam.send(createUserCommand)
.then((result) => {
console.log("User created:", result.User);
})
.catch((error) => {
console.error("An error occurred:", error);
});
```

## 4. Create a Bucket

```powershell
const { S3Client, CreateBucketCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for IAM
const credentials = fromIni({ profile: "default" });
const region = "us-east-1"; // us-east-1 is the default for IAM calls
const endpoint = "https://s3.us-east-1.wasabisys.com";

// Set up the client with the custom endpoint
const s3 = new S3Client({ credentials, region, endpoint });
const BUCKET_NAME = "custom-bucket-name-here"; // Replace with your bucket name

const createBucket = async () => {
try {
const params= {
Bucket: BUCKET_NAME,
};

const data = await s3.send(new CreateBucketCommand(params));
console.log("Success, bucket deleted!", data);
} catch (err) {
console.error("Error", err);
}
};

createBucket();
```

## 5. Upload an existing object to the Bucket

```powershell
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");
const fs = require('fs');

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for S3
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // replace with your S3 bucket region
const endpoint = "https://s3.us-east-1.wasabisys.com"; // replace with your S3 bucket service URL

// Set up the client with the custom endpoint
const s3 = new S3Client({ credentials, region, endpoint });

const BUCKET_NAME = "custom-bucket-name-here"; // Replace with your bucket name
const OBJECT_KEY = "file.png"; // Replace with your object key
const FILE_PATH = "path_to_file.png"; // Replace with the path to your file

const uploadObject = async () => {
try {
const fileStream=fs.createReadStream(FILE_PATH);
const params= {
Bucket: BUCKET_NAME,
Key: OBJECT_KEY,
Body: fileStream,
};

// Upload the object
const data = await s3.send(new PutObjectCommand(params));
console.log("Success, object uploaded", data);
} catch (err) {
console.error("Error", err);
}
};

uploadObject();
```

## 6. Read an object from the Bucket

```powershell
const { S3Client, GetObjectCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for S3
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // replace with your S3 bucket region
const endpoint = "https://s3.us-east-1.wasabisys.com"; // replace with your S3 bucket service URL

// Set up the client with the custom endpoint
const s3 = new S3Client({ credentials, region, endpoint });

const BUCKET_NAME = "custom-bucket-name-here"; // Replace with your bucket name
const OBJECT_KEY = "custom-object-key-name-here"; // Replace with your object key

// Read the object
const readObject = async () => {
try {
const params= {
Bucket: BUCKET_NAME,
Key: OBJECT_KEY
};

const data = await s3.send(new GetObjectCommand(params));
const body = await streamToString(data.Body);

console.log("Success, object retrieved:", body);
} catch (err) {
console.error("Error", err);
}
};

// Function to convert a stream to string
const streamToString = (stream) => {
return new Promise((resolve, reject) => {
const chunks= [];
stream.on('data', (chunk) =>chunks.push(chunk));
stream.on('error', reject);
stream.on('end', () =>resolve(Buffer.concat(chunks).toString('utf8')));
});
};

readObject();
```

## 7. Delete the object from the Bucket

```powershell
const { S3Client, DeleteObjectCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for S3
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // replace with your S3 bucket region
const endpoint = "https://s3.us-east-1.wasabisys.com"; // replace with your S3 bucket service URL

// Set up the client with the custom endpoint
const s3 = new S3Client({ credentials, region, endpoint });
const BUCKET_NAME = "custom-bucket-name-here"; // Replace with your bucket name
const OBJECT_KEY = "custom-object-key-name-here.txt"; // Replace with your object key

const deleteObject = async () => {
try {
const params= {
Bucket: BUCKET_NAME,
Key: OBJECT_KEY
};

const data = await s3.send(new DeleteObjectCommand(params));
console.log("Success, object deleted", data);
} catch (err) {
console.error("Error", err);
}
};

deleteObject();
```

## 8. Delete the Bucket (Bucket must be empty)

```powershell
const { S3Client, DeleteBucketCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-provider-ini");

// Connection
// This is how you can use the .aws credentials file to fetch the credentials, set region, and custom endpoint for S3
const credentials = fromIni({ profile: "wasabi" });
const region = "us-east-1"; // replace with your S3 bucket region
const endpoint = "https://s3.us-east-1.wasabisys.com"; // replace with your S3 bucket service URL

// Set up the client with the custom endpoint
const s3 = new S3Client({ credentials, region, endpoint });
const BUCKET_NAME = "custom-bucket-name-here"; // Replace with your bucket name

const deleteBucket = async () => {
try {
const params= {
Bucket: BUCKET_NAME,
};

const data = await s3.send(new DeleteBucketCommand(params));
console.log("Success, bucket deleted!", data);
} catch (err) {
console.error("Error", err);
}
};

deleteBucket();
```
