Quick Start
Take SST for a spin and create your first project.
0. Prerequisitesβ
SST is built with Node, so make sure your local machine has it installed; at least Node.js 16 and npm 7.
AWS credentialsβ
You also need to have an AWS account and AWS credentials configured locally. If you haven't already, follow these steps.
1. Create a new appβ
Create a new SST app using the create-sst
CLI.
- npm
- yarn
- pnpm
npx create-sst@latest my-sst-app
yarn create sst my-sst-app
pnpm create sst my-sst-app
Install dependenciesβ
Next install the dependencies.
- npm
- yarn
- pnpm
cd my-sst-app
npm install
cd my-sst-app
yarn
cd my-sst-app
pnpm install
2. Start local environmentβ
Then start the Live Lambda local development environment.
- npm
- yarn
- pnpm
npx sst dev
yarn sst dev
pnpm sst dev
The first time you run this command in a project, you'll be prompted to enter a default stage name to use.
Pick a stageβ
SST uses the stage names to namespace your resources.
Look like youβre running sst for the first time in this directory. Please enter
a stage name youβd like to use locally. Or hit enter to use the one based on
your AWS credentials (Jay):
Just hit Enter to select the default one.
Behind the scenes
The name spaced resources lets SST deploy multiple environments of the same app to the same AWS account. So you and your teammates can work together.
The stage name will be stored locally in a .sst/
directory. It's automatically ignored from Git.
The initial deploy can take a few minutes. It will deploy your app to AWS, and also setup the infrastructure to support your local development environment.
Once complete, you'll see something like this.
β App: my-sst-app
Stage: Jay
Console: https://console.sst.dev/my-sst-app/Jay/local
β Deployed:
API
ApiEndpoint: https://bmodl6wkkj.execute-api.us-east-1.amazonaws.com
Now our app has been deployed to AWS and it's connected to our local machine!
Open the consoleβ
The sst dev
command also powers a web based dashboard, called the SST Console. Head over to the URL above or simply β console.sst.dev
Select the API tab on the left, and click Send. This will make a request to the endpoint in AWS.
You should see a Hello world
message in the response.
3. Make a changeβ
Let's make a change to our API and see what the workflow is like. Replace the following in packages/functions/src/lambda.ts
.
export const handler = ApiHandler(async (_evt) => {
return {
- body: `Hello world. The time is ${Time.now()}`,
+ body: "This is my awesome API!",
};
});
Switch back to the SST Console, and click Send again.
You should see the updated message in the response.
4. Deploy to prodβ
Once you are done working on your app locally, you are ready to go to production. We'll use the sst deploy
command for this.
We don't want to use the same stage as our local environment since we want to separate our dev and prod environments. So we'll run the sst deploy
command with the --stage
option.
- npm
- yarn
- pnpm
npx sst deploy --stage prod
yarn sst deploy --stage prod
pnpm sst deploy --stage prod
This will take a few minutes to run and will create a complete new version of your app. Once complete you'll notice these outputs.
β Deployed:
API
ApiEndpoint: https://2q0mwp6r8d.execute-api.us-east-1.amazonaws.com
You'll notice this is a completely new API endpoint.
You can also add custom domains to your app, but we'll cover that in a separate tutorial.
5. Remove the appβ
Finally to wrap this up, you can remove all your app all its resources from AWS.
- npm
- yarn
- pnpm
npx sst remove
npx sst remove --stage prod
yarn sst remove
yarn sst remove --stage prod
pnpm sst remove
pnpm sst remove --stage prod
This removes the local and prod environments of your app.
6. Next stepsβ
If you are ready to dive into the details of SST, check out our tutorial.