To use the AWS SDK for JavaScript v3 in Node.js, install only the service packages you need, for example npm install @aws-sdk/client-s3, create a client, and send a command object with await client.send(new ListBucketsCommand({})). The SDK is modular, supports ES modules and TypeScript, and finds credentials the same way as the AWS CLI. This aws sdk javascript v3 nodejs guide assumes a current Node.js LTS release.
Version 2 of the SDK (the single aws-sdk package) reached end of support in September 2025, so new code should use v3.
Each AWS service has its own package named @aws-sdk/client-<service>. Install only what you use, which keeps bundles and cold starts small.
Set "type": "module" in package.json to use import syntax, as the examples below do. The SDK requires a supported Node.js version; check the SDK's README for the minimum, because it drops end-of-life Node releases.
v3 replaces the v2 style of s3.listBuckets().promise() with a client plus command objects. Every call is a promise, so .promise() is gone.
Top-level await works in ES modules. The Client is created once and reused; each send takes a command that holds the input. Responses are plain objects, so destructuring is natural.
You rarely pass keys. The default provider chain checks, in order, environment variables, the shared ~/.aws/credentials and ~/.aws/config files (including SSO and assume-role profiles), container credentials and the EC2 instance role. To force a profile, set AWS_PROFILE=dev or use the provider package:
Install the helper with npm install @aws-sdk/credential-providers. Do not hard-code access keys in source files.
GetObjectCommand returns a stream in Body. In Node.js v3 adds helper methods so you do not collect chunks manually.
For large files, use Upload from @aws-sdk/lib-storage, which performs multipart uploads and accepts streams. To create temporary download links, use getSignedUrl from @aws-sdk/s3-request-presigner.
The base DynamoDB client needs attribute-type wrappers such as { S: "text" }. The lib-dynamodb package converts native JavaScript values for you.
Paginated operations have helper functions named paginate<Operation>, which return async iterables.
Errors are thrown as exceptions with a name and $metadata. Check the name instead of parsing messages:
Service packages also export typed exception classes, such as NoSuchKey, that you can test with instanceof.
The main changes when moving from v2:
| v2 | v3 |
|---|---|
import AWS from "aws-sdk" | import { S3Client } from "@aws-sdk/client-s3" |
s3.getObject(params).promise() | await s3.send(new GetObjectCommand(params)) |
| Whole SDK in one package | One package per service |
| Callbacks and promises | Promises only |
| Types bundled separately | Types included in each package |
AWS publishes a codemod, aws-sdk-js-codemod, that rewrites many v2 calls to v3 automatically. v3 is written in TypeScript, so each command's input and output types are available with no extra install.
Use v3. The v2 aws-sdk package is no longer supported, while v3 is modular, typed and receives new service features.
Set AWS_PROFILE in the environment, or pass credentials: fromIni({ profile }) from @aws-sdk/credential-providers to the client.
GetObjectCommand returns a stream. Call await response.Body.transformToString() or transformToByteArray() to read it.
Yes. Use const { S3Client } = require("@aws-sdk/client-s3"), though ES modules are the better long-term choice and enable top-level await.
Install the @aws-sdk/client-* packages you need, create one client per service, and call await client.send(new SomeCommand(input)). Let the default credential chain supply keys, use lib-dynamodb, lib-storage and paginators for common tasks, and migrate off v2 as soon as you can.