Skip to content

Getting started

Start a new project

Starter projects are working apps with their Stacktape configuration already written: APIs, full-stack apps, workers, AI agents and more. stacktape init copies one into a new directory and prints the commands that deploy it.

This guide uses the Hono API starter, a small TypeScript API that runs in a Lambda function behind an HTTP API Gateway. It deploys in a few minutes and costs close to nothing while nobody calls it. The steps are the same for every starter.

1. Create the project

Run this in the directory where the project folder should go:

stacktape init --starter-id hono-api \  --initialize-project-to ./hono-api --config-format yaml
  • --starter-id is the starter's ID. Each card in Starter projects shows it.
  • --initialize-project-to is the new directory. If it exists and isn't empty, the CLI warns you and asks Continue?. Answering yes deletes everything in it.
  • --config-format is yaml or typescript.

To choose interactively, run stacktape init --starter-project. The CLI asks three things: Choose a starter project, Where to create the project? (stacktape-project by default, . for the current directory) and Config format.

The CLI downloads the starter from GitHub and prints a summary:

  • where the project is and which config file it has,
  • the resources and their monthly price, when it can be estimated,
  • the region it picked and why,
  • the commands to run next.

The last part looks like this:

Navigate to the project:  cd ./hono-apiRun hybrid-local dev mode (deploys minimal, free dev stack to AWS):  stacktape dev --project hono-api --stage local --region eu-west-1Deploy to AWS:  stacktape deploy --project hono-api --stage dev --region eu-west-1

The region is the one your AWS setup uses, from AWS_DEFAULT_REGION or AWS_REGION, your Stacktape defaults or your AWS profile, or eu-west-1 when none is set. Change --region in the commands if you want another one.

2. Look at what you got

hono-api/├── src/index.ts      the API: GET /, GET /posts and POST /posts├── stacktape.yml     two resources: apiGateway and api└── package.json

stacktape.yml declares an HTTP API Gateway (apiGateway) and a Lambda function (api) that bundles src/index.ts. Every request to the gateway goes to the function.

You don't need to run npm install first. The deploy installs dependencies when they changed.

3. Set the secrets, if the starter has any

Some starters need values only you have, such as an API key for an external service. For those, the summary lists one command per secret before the deploy command:

stacktape secret set <name> --region eu-west-1

It asks for the value and stores it as a secret in your AWS account. The Hono starter has no secrets. Database passwords are generated by the deploy, so they are never on this list.

4. Deploy

Deploying needs AWS credentials on your machine. If you don't have them yet, see Set up AWS credentials.

cd ./hono-apistacktape deploy --project hono-api --stage dev --region eu-west-1

The CLI says which AWS credentials it uses, builds the function, uploads it to your AWS account and creates a CloudFormation stack named after the project and stage, hono-api-dev. The first deploy of this starter takes a few minutes. Starters with a database or a container service take longer.

When it's done, the CLI prints the URL of the API Gateway.

5. Check that it works

Open the URL in your browser, or call it:

curl https://<api-id>.execute-api.eu-west-1.amazonaws.com/
JSON
{ "message": "Hello from Hono on AWS Lambda!" }

/posts returns two sample posts. If you get an error, read the function's logs:

stacktape logs api --project hono-api --stage dev --region eu-west-1

api is the resource name from stacktape.yml. After the first deploy covers redeploying, more stages and deleting the stack.

What it costs

AWS bills your AWS account for the resources. The Hono starter is pay-per-request: Lambda and HTTP API Gateway charge per request and have a free tier, so a test deployment that nobody calls costs close to nothing. Starters with a database, a container service or a load balancer cost money every hour they exist. Check the monthly price in the summary before you deploy, and delete the stage when you're done trying it.

The CLI is free. You don't need a Stacktape account.

Starters with TypeScript configs

With --config-format typescript, the project gets a stacktape.ts that imports from the stacktape npm package. Keep that package on the same version as your CLI (stacktape version prints it):

npm install --save-dev stacktape@<cli-version>

Dev mode

The summary also prints a stacktape dev command. Dev mode runs your code on your machine against a small stack in AWS, so you see changes without a full deploy. It uses its own stage, local, because a stage created by dev mode can't be deployed with stacktape deploy. See Dev mode.