---
title: "JavaScript SDK"
description: "Use the AWS S3 SDK with Edge Storage, and fetch() for Compute, CDN, and DNS. Practical examples for uploading files and generating presigned share links."
url: https://edge.network/academy/sdk-javascript/
---

# JavaScript SDK

[Back to Academy](https://edge.network/academy)
API & SDK
10 min read

# JavaScript SDK

Edge does not provide its own JavaScript SDK. For Storage, use the standard AWS S3 SDK. For Compute, CDN, and DNS, use the REST API with `fetch()`.

## How it works

Edge Storage is S3-compatible. Use `@aws-sdk/client-s3`
with Edge's endpoint and credentials. For Compute, CDN, and DNS, call the REST API at
`https://api.edge.network`
using `fetch()` with your API key.

## Storage: Installing and configuring

Install the AWS S3 client and presigner (for presigned URLs):

```
npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
```

Configure the client with Edge's Storage endpoint and your access credentials (found in **Control Panel → Storage → Access Keys**):

```
import { S3Client, CreateBucketCommand, PutObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'

const s3 = new S3Client({
  region: 'us-east-1',
  endpoint: 'https://storage.edge.network',
  forcePathStyle: true,
  credentials: {
    accessKeyId: process.env.EDGE_ACCESS_KEY,
    secretAccessKey: process.env.EDGE_SECRET_KEY
  }
})
```

Use `forcePathStyle: true` — Edge Storage requires path-style access (e.g. `storage.edge.network/bucket/key`).

## Storage operations

**Create a bucket:**

```
await s3.send(new CreateBucketCommand({ Bucket: 'my-bucket' }))
```

**Upload a file:**

```
await s3.send(new PutObjectCommand({
  Bucket: 'my-bucket',
  Key: 'uploads/image.jpg',
  Body: fileBuffer,
  ContentType: 'image/jpeg'
}))
```

**List objects:**

```
const { Contents } = await s3.send(new ListObjectsV2Command({
  Bucket: 'my-bucket',
  Prefix: 'uploads/'
}))
```

**Download a file:**

```
const { Body } = await s3.send(new GetObjectCommand({
  Bucket: 'my-bucket',
  Key: 'uploads/image.jpg'
}))
const data = await Body.transformToByteArray()
```

**Generate a presigned URL:**

```
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
const url = await getSignedUrl(s3, new GetObjectCommand({
  Bucket: 'my-bucket',
  Key: 'uploads/image.jpg'
}), { expiresIn: 3600 })
```

## Compute, CDN, DNS: REST API with fetch

For non-Storage products, use `fetch()` against the Edge API:

```
const response = await fetch('https://api.edge.network/api/compute/vms', {
  headers: {
    'Authorization': `Bearer ${process.env.EDGE_API_KEY}`,
    'Content-Type': 'application/json'
  }
})
const { data } = await response.json()
```

Use the same pattern for CDN deployments, DNS zones and records, and VM power operations. See the [API Reference](https://edge.network/academy/api-reference) for endpoint details.

## Practical example: Upload image and get share link

Here's a complete example that uploads an image and returns a presigned share link:

```
async function uploadAndShare(buffer, filename) {
  const key = `uploads/${Date.now()}-${filename}`
  
  await s3.send(new PutObjectCommand({
    Bucket: 'my-bucket',
    Key: key,
    Body: buffer,
    ContentType: 'image/jpeg'
  }))
  
  const shareUrl = await getSignedUrl(s3, new GetObjectCommand({
    Bucket: 'my-bucket',
    Key: key
  }), { expiresIn: 86400 }) // 24 hours
  
  return shareUrl
}
```

Call this from an API route or serverless function. The returned URL can be shared with users — they can view or download the file without authenticating, until the URL expires.

## Next steps

[Python SDK](https://edge.network/academy/sdk-python) [Storage Documentation](https://edge.network/docs/storage)
