This is an introduction blog post to a new framework called SST
serverless-stack / sst
💥 SST makes it easy to build full-stack serverless apps.
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"
}
});
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"
}
});
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]);
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"]);
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
}
});
and this is just the surface, want to explore more?
⭐️ on GitHub to support us!
Top comments (0)