DEV Community

Alex Spinov
Alex Spinov

Posted on

SST Has a Free API Framework That Deploys Full-Stack Apps to AWS in Minutes

SST (Serverless Stack) is the framework that makes AWS simple. Define APIs, databases, cron jobs, and queues in TypeScript — SST handles the CloudFormation.

What Is SST?

SST v3 (code-named Ion) uses Pulumi under the hood to deploy to AWS. But you write simple TypeScript, not CloudFormation YAML.

Quick Start

npx sst@latest init
npx sst dev  # Live development with hot reload
Enter fullscreen mode Exit fullscreen mode

Define Infrastructure in Code

// sst.config.ts
export default $config({
  app(input) {
    return { name: 'my-app', home: 'aws' }
  },
  async run() {
    // API
    const api = new sst.aws.Function('MyApi', {
      handler: 'src/api.handler',
      url: true,
    })

    // Database
    const table = new sst.aws.Dynamo('Users', {
      fields: { userId: 'string', email: 'string' },
      primaryIndex: { hashKey: 'userId' },
    })

    // Cron job
    new sst.aws.Cron('DailyReport', {
      schedule: 'rate(1 day)',
      function: 'src/cron/report.handler',
    })

    // Queue
    const queue = new sst.aws.Queue('EmailQueue', {
      consumer: 'src/queue/send-email.handler',
    })

    // Bucket
    const bucket = new sst.aws.Bucket('Uploads')

    // Link resources to functions
    api.link([table, queue, bucket])

    return { apiUrl: api.url }
  },
})
Enter fullscreen mode Exit fullscreen mode

API Handler

// src/api.ts
import { Resource } from 'sst'
import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb'

const db = new DynamoDBClient()

export async function handler(event: any) {
  const userId = event.pathParameters?.id

  const result = await db.send(new GetItemCommand({
    TableName: Resource.Users.name,
    Key: { userId: { S: userId } },
  }))

  return {
    statusCode: 200,
    body: JSON.stringify(result.Item),
  }
}
Enter fullscreen mode Exit fullscreen mode

Full-Stack: Next.js + SST

// sst.config.ts
export default $config({
  async run() {
    const table = new sst.aws.Dynamo('Todos', {
      fields: { id: 'string' },
      primaryIndex: { hashKey: 'id' },
    })

    new sst.aws.Nextjs('Web', {
      link: [table],
    })
  },
})
Enter fullscreen mode Exit fullscreen mode

SST deploys your Next.js app to AWS with Lambda@Edge, S3, and CloudFront — automatically.

Live Development

npx sst dev
# Changes to your Lambda functions are reflected in ~10ms
# No redeployment needed — SST proxies through your local machine
Enter fullscreen mode Exit fullscreen mode

Deploy

npx sst deploy --stage production
Enter fullscreen mode Exit fullscreen mode

SST vs Serverless Framework vs CDK

Feature SST Serverless CDK
Language TypeScript YAML TypeScript
Live dev Yes (10ms) No No
Full-stack Next.js, Remix, Astro API only Low-level
Resource linking Automatic Manual env vars Manual
DX Best Good Complex

Deploying scraping infrastructure on AWS? Scrapfly handles it all — no AWS needed. Email spinov001@gmail.com for managed scraping.

Top comments (0)