DEV Community

Cover image for ⚡️Serverless-stack⚡️ Build full-stack serverless apps on AWS!
Manitej ⚡
Manitej ⚡

Posted on

⚡️Serverless-stack⚡️ Build full-stack serverless apps on AWS!

This is an introduction blog post to a new framework called SST

GitHub logo serverless-stack / serverless-stack

💥 Serverless Stack (SST) is a framework that makes it easy to build serverless apps. Set breakpoints and test your functions locally.

What is SST?

Serverless Stack (SST) is an open-source framework that makes it easy to build serverless applications on AWS. It supports various frameworks like React, Vue, Angular, Svelte and much more!

🔥 Features

Live Lambda Development

Work on your local Lambda functions live, without mocking or redeploying your app.

Breakpoint debugging

Use your favourite IDE like Visual Studio code, WebStorm, Intellij and set breakpoints to debug your Lambda functions.

Composable serverless constructs

Higher-level CDK constructs made specifically for building serverless apps.

and much more!

✨ Examples

Okay, enough talk want to see some actual code? sure, go ahead.

Want to create a REST API?

Here you go,

new sst.Api(this, "Api", {
  routes: {
    "GET /notes": "src/list.main",
    "GET /notes/{id}": "src/get.main",
    "PUT /notes/{id}": "src/update.main"
  }
});
Enter fullscreen mode Exit fullscreen mode

No REST, GraphQL please!

alright!

new sst.AppSyncApi(this, "Api", {
  graphqlApi: { schema: "schema.graphql" },
  resolvers: {
    "Query get": "src/get.main",
    "Query list": "src/list.main",
    "Mutation update": "src/update.main"
  }
});
Enter fullscreen mode Exit fullscreen mode

Want user auth? it's a piece of 🍰

Here's an example code to add Facebook auth

const api = new sst.Api(this, "Api", {
  defaultAuthorizationType:
    sst.ApiAuthorizationType.AWS_IAM,
  routes: {
    "GET /private": "src/private.main"
  }
});

const auth = new sst.Auth(this, "Auth", {
  facebook: { appId: "419718329085014" }
});

// Allow auth users to access the API
auth.attachPermissionsForAuthUsers([api]);
Enter fullscreen mode Exit fullscreen mode

CRON jobs?

Too easy!

new sst.Cron(this, "Cron", {
  job: "src/lambda.main",
  schedule: "rate(1 minute)"
});

// Allow access to other resources
api.attachPermissions(["s3"]);
Enter fullscreen mode Exit fullscreen mode

Full-stack react app hosted on AWS?

We need 6 lines of code to do that,

new sst.ReactStaticSite(this, "Site", {
  path: "src/frontend",
  customDomain: "www.my-react-app.com",
  environment: {
    REACT_APP_API_URL: api.url
  }
});
Enter fullscreen mode Exit fullscreen mode

and this is just the surface, want to explore more?

⭐️ on GitHub to support us!

GitHub logo serverless-stack / serverless-stack

💥 Serverless Stack (SST) is a framework that makes it easy to build serverless apps. Set breakpoints and test your functions locally.

Website: here
Follow on Twitter: here
Join slack: here

Discussion (0)