Create a New Project
Let's create our first SST app!
Prerequisitesโ
- SST is built with Node, so make sure your local machine has it installed; Node.js 18 and npm 7.
- And we'll need a code editor. We use VS Code in this tutorial.
- Some basic TypeScript, AWS, or React knowledge would help, but it's not necessary.
Configure AWS credentialsโ
You also need to have an AWS account and AWS credentials configured locally. If you haven't already, follow these steps.
Create a new appโ
Let's create our starter. We'll be using the create sst
CLI.
- npm
- yarn
- pnpm
npx create-sst@two --template=graphql/rds
yarn create sst --template=graphql/rds
pnpm create sst --template=graphql/rds
tip
In this tutorial, we'll be using the keyboard icon for code snippets where we want you to make a change.
Select a name for your app. We'll just use the default.
? Project name (my-sst-app)
Next, install the dependencies.
- npm
- yarn
- pnpm
cd my-sst-app
npm install
cd my-sst-app
yarn
cd my-sst-app
pnpm install
The create sst
CLI by default bootstraps a full-stack starter that we'll be using in this tutorial. It can also create a more minimal setup, if you don't pass in --template
. We recommend going that route if you want to piece your stack together.
Start Live Lambda Devโ
Let's start our local development environment. Or what SST calls Live Lambda Dev.
npx sst dev
The first time the SST command is run, you'll be prompted to enter a default stage name to use. The stage name will be stored locally in a .sst/
directory; it's automatically ignored from Git.
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):
SST uses the stage names to namespace your resources. So if you and your teammate are working on the same app in the same AWS account, the infrastructure will be kept separate.
SST will automatically suggest a stage name based on the AWS credentials you are using. Hit Enter to use the suggested one.
tip
Make sure to use a unique stage name when working on an SST app locally.
Or if you are picking your own, make sure to use a stage name that is specific to you.
About sst dev
โ
The sst dev
command, as you might've guessed, deploys to your AWS account. It does a couple of interesting things:
- Bootstraps your AWS account for SST. This only needs to be done once per account.
- Setups up the Live Lambda Dev environment.
- Deploys your app to AWS.
- Runs a local server to:
- Proxy Lambda requests to your local machine.
- Power the SST Console. More on this later.
info
The sst dev
command starts up the Live Lambda Dev environment.
The first time you run sst dev
in a new AWS region and account, it can take around 5 minutes to set everything up.
Editor integrationโ
While sst dev
is starting up, let's open your project in your code editor. We are using VS Code in our case.
SST is designed to integrate really well with your code editor. It features automatic support for:
- Breakpoint debugging
- Type checking
- Autocomplete
- Inline docs
You can read more about this over on our doc on Editor Integration.
Next, let's take a look at the project structure of an SST app.