### Create a TanStack Start project Source: https://sst-community.github.io/sst/docs/start/aws/tanstack Creates a new TanStack Start project. The init wizard prompts for project name, Tailwind, toolchain, deployment adapter, add-ons, and examples. Choose 'Nitro (agnostic)' as the deployment adapter to get Nitro pre-installed. ```bash npm create @tanstack/start@latest ``` -------------------------------- ### Install SST tunnel (sudo sst tunnel install) Source: https://sst-community.github.io/sst/docs/live Install the tunnel with sudo to create the network interface. This is a one-time setup step. ```bash sudo sst tunnel install ``` -------------------------------- ### Install Python packages with uv Source: https://sst-community.github.io/sst/docs/component/aws/function Installs all packages in the uv workspace before starting `sst dev`. ```bash uv sync --all-packages ``` -------------------------------- ### Init Bun Serve with index.ts Source: https://sst-community.github.io/sst/docs/start/aws/bun Replaces the default index.ts with a Bun HTTP server that responds with 'Hello World!' on GET / and '404!' otherwise. Starts on port 3000 by default. ```js const server = Bun.serve({ async fetch(req) { const url = new URL(req.url); if (url.pathname === "/" && req.method === "GET") { return new Response("Hello World!"); } return new Response("404!"); }, }); console.log(`Listening on ${server.url}`); ``` -------------------------------- ### Run a task and get task ARN Source: https://sst-community.github.io/sst/docs/component/aws/task Example of running a task and retrieving the task ARN from the response. This is used as a prerequisite for the describe example. ```js const runRet = await task.run(Resource.MyTask); const taskArn = runRet.tasks[0].taskArn; ``` -------------------------------- ### Importing the Example module Source: https://sst-community.github.io/sst/docs/set-up-a-monorepo Import the 'Example' module from the core package using the configured exports. ```ts import { Example } from "@monorepo-template/core/example"; Example.hello(); ``` -------------------------------- ### Install the Node.js adapter Source: https://sst-community.github.io/sst/docs/start/aws/svelte Installs the Node.js adapter for SvelteKit, required for container deployment. ```bash npm i -D @sveltejs/adapter-node ``` -------------------------------- ### Install dependencies Source: https://sst-community.github.io/sst/docs/start/aws/auth Installs the required npm packages for OpenAuth, valibot, and Hono. ```bash npm install @openauthjs/openauth valibot hono ``` -------------------------------- ### Install dependencies Source: https://sst-community.github.io/sst/docs/set-up-a-monorepo Run this command from the project root to install all dependencies for the monorepo. ```bash npm install ``` -------------------------------- ### Install npm Packages with Deno Source: https://sst-community.github.io/sst/docs/start/aws/deno Installs the required npm packages for SST and AWS SDK using Deno's install command. ```bash deno install npm:sst npm:@aws-sdk/client-s3 npm:@aws-sdk/lib-storage npm:@aws-sdk/s3-request-presigner ``` -------------------------------- ### Start SST dev mode Source: https://sst-community.github.io/sst/docs/start/aws/analog Starts the SST development environment. ```bash npx sst dev ``` -------------------------------- ### Describe a task with task ARN Source: https://sst-community.github.io/sst/docs/component/aws/task Example of using the describe method to get details of a previously started task, using the task ARN obtained from the run response. ```js const describeRet = await task.describe(Resource.MyTask, taskArn); console.log(describeRet.status); ``` -------------------------------- ### Deploy a SolidStart app from project root Source: https://sst-community.github.io/sst/docs/component/aws/solid-start Minimal example that deploys a SolidStart app located in the project root. The component is instantiated with just a name. ```typescript new sst.aws.SolidStart("MyWeb"); ``` -------------------------------- ### Initialize Deno project Source: https://sst-community.github.io/sst/docs/start/aws/deno Initializes a new Deno project named aws-deno. ```bash deno init aws-deno ``` -------------------------------- ### Create project directory and initialize npm Source: https://sst-community.github.io/sst/docs/start/aws/email Creates a new directory for the SST app and initializes a Node.js project. ```bash mkdir my-email-app && cd my-email-app npm init -y ``` -------------------------------- ### Output User Pool ID Source: https://sst-community.github.io/sst/docs/component/aws/cognito-user-pool Example of outputting the User Pool ID to find the ID used in the static get example. ```ts return { userPool: userPool.id }; ``` -------------------------------- ### Initialize SST with bunx Source: https://sst-community.github.io/sst/docs/start/aws/bun Initializes SST in the project, creating an sst.config.ts file, and installs dependencies. ```bash bunx sst init bun install ``` -------------------------------- ### Create Analog project Source: https://sst-community.github.io/sst/docs/start/aws/analog Initializes a new Analog project and changes into the project directory. ```bash npm create analog@latest cd aws-analog ``` -------------------------------- ### Create a SolidStart project Source: https://sst-community.github.io/sst/docs/start/aws/solid Initializes a new SolidStart project with the basic TypeScript template. ```bash npm init solid@latest aws-solid-start cd aws-solid-start ``` -------------------------------- ### Get existing OpenSearch domain with static get Source: https://sst-community.github.io/sst/docs/component/aws/open-search Use the static get method to reference an existing OpenSearch domain, useful for sharing a domain across stages. The example shows conditionally creating a new domain or getting an existing one based on the stage. ```ts const search = $app.stage === "frank" ? sst.aws.OpenSearch.get("MyOpenSearch", "app-dev-myopensearch-efsmkrbt") : new sst.aws.OpenSearch("MyOpenSearch"); ``` -------------------------------- ### Single-region cluster with Dsql.get Source: https://sst-community.github.io/sst/docs/component/aws/dsql Example of using `static get` for a single-region cluster. It conditionally gets an existing cluster or creates a new one based on the stage. ```ts const cluster = $app.stage === "frank" ? sst.aws.Dsql.get("MyCluster", { id: "kzttrvbdg4k2o5ze2m2rrwdj7u" }) : new sst.aws.Dsql("MyCluster"); ``` -------------------------------- ### Create Express project Source: https://sst-community.github.io/sst/docs/start/aws/express Creates a new project directory, initializes a Node.js project, and installs Express. ```bash mkdir aws-express && cd aws-express npm init -y npm install express ``` -------------------------------- ### Get an existing Hyperdrive config with static get Source: https://sst-community.github.io/sst/docs/component/cloudflare/hyperdrive Use the static get method to reference an existing Hyperdrive config by ID. This example shows conditionally creating a new config in the 'frank' stage or retrieving the one from the 'dev' stage. ```ts const hyperdrive = $app.stage === "frank" ? sst.cloudflare.Hyperdrive.get("MyDatabase", { hyperdriveId: "a1b2c3d4e5f6", }) : new sst.cloudflare.Hyperdrive("MyDatabase", { ... }); ``` -------------------------------- ### Backup v2 config and init v3 app Source: https://sst-community.github.io/sst/docs/migrate-from-v2 Backs up the v2 config and initializes a new v3 app. Use the same app name as the v2 app. ```bash mv sst.config.ts sst.config.ts.bk ``` ```bash npx sst init ``` -------------------------------- ### Start tunnel for a specific stage with sst tunnel --stage Source: https://sst-community.github.io/sst/docs/reference/cli Starts a tunnel manually to connect to a different stage. Requires a network interface created with sst tunnel install. ```bash sst tunnel --stage production ``` -------------------------------- ### Initialize an SST app with sst init Source: https://sst-community.github.io/sst/docs/basics Initializes a new SST app. Run this before using the other commands. ```bash sst init ``` -------------------------------- ### static get usage example Source: https://sst-community.github.io/sst/docs/component/aws/router Shares a Router across stages by referencing an existing Router distribution ID. ```ts const router = $app.stage === "frank" ? sst.aws.Router.get("MyRouter", "E2IDLMESRN6V62") : new sst.aws.Router("MyRouter"); ``` -------------------------------- ### Create a Bun project Source: https://sst-community.github.io/sst/docs/start/aws/bun Creates a new directory for the Bun app and initializes a Bun project with default settings. ```bash mkdir aws-bun && cd aws-bun bun init -y ``` -------------------------------- ### Existing bus and queue setup Source: https://sst-community.github.io/sst/docs/component/aws/bus Defines an existing EventBus ARN and creates an SQS Queue for the subscribeQueue example. ```js const busArn = "arn:aws:events:us-east-1:123456789012:event-bus/MyBus"; const queue = new sst.aws.Queue("MyQueue"); ``` -------------------------------- ### Initialize SST Source: https://sst-community.github.io/sst/docs/start/aws/analog Initializes SST in the project and installs dependencies. ```bash npx @sst-community/sst@latest init npm install ``` -------------------------------- ### static get method signature and usage Source: https://sst-community.github.io/sst/docs/component/aws/alb Defines the static get method that takes a name, load balancer ARN, and optional component resource options, returning an Alb instance. The example references an existing ALB by its ARN. ```typescript Alb.get(name, loadBalancerArn, opts?) ``` ```typescript const alb = sst.aws.Alb.get("SharedAlb", "arn:aws:elasticloadbalancing:..."); ``` -------------------------------- ### Share an EventBus across stages with static get Source: https://sst-community.github.io/sst/docs/component/aws/bus Uses the static get method to reference an existing EventBus from another stage, avoiding creating a new one. The example conditionally uses the bus from the 'dev' stage when in the 'frank' stage. ```typescript const bus = $app.stage === "frank" ? sst.aws.Bus.get("MyBus", "app-dev-MyBus") : new sst.aws.Bus("MyBus"); ``` -------------------------------- ### Create a new SvelteKit project Source: https://sst-community.github.io/sst/docs/start/aws/svelte Initializes a new SvelteKit project with the 'sv create' command and navigates into the project directory. Select the 'SvelteKit minimal' and 'Yes, using TypeScript syntax' options when prompted. ```bash npx sv create aws-svelte-kit cd aws-svelte-kit ``` -------------------------------- ### Add AWS provider Source: https://sst-community.github.io/sst/docs/reference/cli Example of adding the AWS provider. This installs the package, adds 'aws' to the globals in sst.config.ts, and adds it to the providers. ```bash sst add aws ``` -------------------------------- ### new TanStackStart(name, args?, opts?) Source: https://sst-community.github.io/sst/docs/component/cloudflare/tan-stack-start Creates a new TanStackStart component instance. The constructor takes a name, optional configuration arguments, and optional component resource options. ```APIDOC ## new TanStackStart(name, args?, opts?) ### Description Creates a new TanStackStart component instance. ### Constructor `new TanStackStart(name, args?, opts?)` ### Parameters - `name` (string) - Required - The name of the component. - `args?` (TanStackStartArgs) - Optional - Configuration arguments for the component. - `opts?` (ComponentResourceOptions) - Optional - Pulumi component resource options. ### Example ```ts new TanStackStart("my-app", { path: "packages/web", domain: "my-app.com" }); ``` ``` -------------------------------- ### Multi-region cluster with Dsql.get Source: https://sst-community.github.io/sst/docs/component/aws/dsql Example of using `static get` for a multi-region cluster, specifying the peer cluster's ID and region. ```ts const cluster = sst.aws.Dsql.get("MyCluster", { id: "app-dev-mycluster", peer: { id: "kzttrvbdg4k2o5ze2m2rrwdj7u", region: "us-east-2", } }); ``` -------------------------------- ### Minimal example: sst.config.ts Source: https://sst-community.github.io/sst/docs/component/aws/workflow Creates a new sst.aws.Workflow component with a handler pointing to src/workflow.handler. This is the basic setup for adding a workflow to your app. ```ts new sst.aws.Workflow("MyWorkflow", { handler: "src/workflow.handler", }); ``` -------------------------------- ### Run a script with sst shell Source: https://sst-community.github.io/sst/docs/set-up-a-monorepo Run the example script from the 'packages/scripts/' directory using the 'sst shell' CLI. ```bash npm run shell src/example.ts ``` -------------------------------- ### Configure CORS allowMethods Source: https://sst-community.github.io/sst/docs/component/aws/bucket Sets the HTTP methods allowed when calling the bucket. Default is ["DELETE", "GET", "HEAD", "POST", "PUT"]. This example restricts to GET, POST, DELETE. ```js { cors: { allowMethods: ["GET", "POST", "DELETE"] } } ``` -------------------------------- ### Run a command with sst dev in basic mode Source: https://sst-community.github.io/sst/docs/reference/cli In basic mode, start the frontend separately by passing a command to `sst dev`. This loads linked resources in the environment. ```bash sst dev next dev ``` -------------------------------- ### Create a Node.js project Source: https://sst-community.github.io/sst/docs/start/aws/prisma Creates a new project directory and initializes a Node.js app with npm. ```bash mkdir aws-prisma && cd aws-prisma npm init -y ``` -------------------------------- ### Output database and proxy IDs Source: https://sst-community.github.io/sst/docs/component/aws/mysql Output the database ID and proxy ID in the 'dev' stage to find the values used in the static get example. ```ts return { id: database.id, proxyId: database.proxyId }; ``` -------------------------------- ### SolidStartSite v2 Source: https://sst-community.github.io/sst/docs/migrate-from-v2 v2 example for SolidStartSite. Uses the old SolidStartSite construct with customDomain. ```ts new SolidStartSite(stack, "MyWeb", { customDomain: "my-app.com" }); ``` -------------------------------- ### Output EFS file system ID Source: https://sst-community.github.io/sst/docs/component/aws/efs Output the file system ID in the 'dev' stage to find the ID used in the static get example. ```ts return { id: efs.id }; ``` -------------------------------- ### Share User Pool across stages Source: https://sst-community.github.io/sst/docs/component/aws/cognito-user-pool Example of conditionally sharing a User Pool from the 'dev' stage in the 'frank' stage using static get. ```ts const userPool = $app.stage === "frank" ? sst.aws.CognitoUserPool.get("MyUserPool", "us-east-1_gcF5PjhQK") : new sst.aws.CognitoUserPool("MyUserPool"); ``` -------------------------------- ### Specify provider version in sst.config.ts Source: https://sst-community.github.io/sst/docs/reference/cli Example of specifying a specific version for the AWS provider in sst.config.ts. You'll need to run 'sst install' after updating the providers. ```ts { providers: { aws: { package: "@pulumi/aws", version: "6.26.0" } } } ``` -------------------------------- ### Show global help Source: https://sst-community.github.io/sst/docs/reference/cli Prints the global help for the CLI. ```sh sst --help ``` -------------------------------- ### new SolidStart(name, args?, opts?) Source: https://sst-community.github.io/sst/docs/component/aws/solid-start Creates a new SolidStart component to deploy a SolidStart app to AWS. Accepts a name, optional configuration arguments, and optional Pulumi component resource options. ```APIDOC ## new SolidStart(name, args?, opts?) ### Description Creates a new SolidStart component to deploy a SolidStart app to AWS. ### Constructor ```ts new SolidStart(name, args?, opts?) ``` ### Parameters - **name** (`string`) - Required - The name of the component. - **args?** (`SolidStartArgs`) - Optional - Configuration arguments for the SolidStart component. - **opts?** (`ComponentResourceOptions`) - Optional - Pulumi component resource options. ### Usage Examples #### Minimal example Deploy a SolidStart app that's in the project root. ```js title="sst.config.ts" new sst.aws.SolidStart("MyWeb"); ``` #### Change the path Deploys the SolidStart app in the `my-solid-app/` directory. ```js title="sst.config.ts" new sst.aws.SolidStart("MyWeb", { path: "my-solid-app/" }); ``` #### Add a custom domain Set a custom domain for your SolidStart app. ```js title="sst.config.ts" new sst.aws.SolidStart("MyWeb", { domain: "my-app.com" }); ``` #### Redirect www to apex domain Redirect `www.my-app.com` to `my-app.com`. ```js title="sst.config.ts" new sst.aws.SolidStart("MyWeb", { domain: { name: "my-app.com", redirects: ["www.my-app.com"] } }); ``` #### Link resources Link resources to your SolidStart app. This grants permissions to the resources and allows you to access them in your app. ```ts title="sst.config.ts" const bucket = new sst.aws.Bucket("MyBucket"); new sst.aws.SolidStart("MyWeb", { link: [bucket] }); ``` You can use the SDK to access the linked resources in your SolidStart app. ```ts title="src/app.tsx" import { Resource } from "sst"; console.log(Resource.MyBucket.name); ``` ``` -------------------------------- ### Function components with and without runtime override Source: https://sst-community.github.io/sst/docs/components Example components created after the `$transform` call. `MyFunctionA` gets the default runtime `nodejs18.x`, while `MyFunctionB` overrides it with `nodejs20.x`. ```ts new sst.aws.Function("MyFunctionA", { handler: "src/lambdaA.handler" }); new sst.aws.Function("MyFunctionB", { handler: "src/lambdaB.handler", runtime: "nodejs20.x" }); ``` -------------------------------- ### Install Drizzle and pg client Source: https://sst-community.github.io/sst/docs/start/aws/drizzle Adds Drizzle ORM, Drizzle Kit, and the pg client to the project. ```bash npm install pg @types/pg drizzle-orm drizzle-kit ``` -------------------------------- ### Pin a specific provider version Source: https://sst-community.github.io/sst/docs/providers Example of pinning a specific version for a provider using the `version` option. By default, SST installs the latest version, but you can override it. ```ts { providers: { aws: { version: "6.27.0" } } } ``` -------------------------------- ### Share Identity Pool across stages with static get Source: https://sst-community.github.io/sst/docs/component/aws/cognito-identity-pool Example from sst.config.ts that conditionally uses the static get method to share an Identity Pool from the dev stage when the current stage is 'frank', otherwise creates a new one. The identity pool ID is provided as a literal string. ```ts const identityPool = $app.stage === "frank" ? sst.aws.CognitoIdentityPool.get("MyIdentityPool", "us-east-1:02facf30-e2f3-49ec-9e79-c55187415cf8") : new sst.aws.CognitoIdentityPool("MyIdentityPool"); ``` -------------------------------- ### new StaticSite(name, args?, opts?) Source: https://sst-community.github.io/sst/docs/component/aws/static-site Creates a new StaticSite component. The constructor takes a name, optional configuration arguments, and optional component resource options. ```APIDOC ## new StaticSite(name, args?, opts?) ### Description Creates a new StaticSite component. ### Parameters - `name` (string) - Required - The name of the static site. - `args?` (StaticSiteArgs) - Optional - Configuration for the static site. - `opts?` (ComponentResourceOptions) - Optional - Pulumi component resource options. ### Example ```ts new StaticSite("my-site", { assets: { path: "public" } }); ``` ``` -------------------------------- ### Create a Node.js project Source: https://sst-community.github.io/sst/docs/start/aws/drizzle Initializes a new Node.js app in the aws-drizzle directory. ```bash mkdir aws-drizzle && cd aws-drizzle npm init -y ``` -------------------------------- ### Run sst dev with npm, pnpm, Bun, or Yarn Source: https://sst-community.github.io/sst/docs Run the `sst dev` command using your package manager after installing the CLI locally. This starts the local development environment. ```bash npx sst dev ``` ```bash pnpm exec sst dev ``` ```bash bun sst dev ``` ```bash yarn sst dev ``` -------------------------------- ### Use the SDK to list bucket contents Source: https://sst-community.github.io/sst/docs/component/cloudflare/bucket Once linked, you can use the SST SDK to interact with the bucket. This example lists the contents of the bucket. ```ts import { Resource } from "sst"; await Resource.MyBucket.list(); ``` -------------------------------- ### Install Redis and router packages Source: https://sst-community.github.io/sst/docs/start/aws/solid Installs the ioredis and @solidjs/router packages needed to connect to Redis and use the router. ```bash npm install ioredis @solidjs/router ``` -------------------------------- ### Set resource ARN for task Source: https://sst-community.github.io/sst/docs/component/aws/step-functions/task Set the resource property to the ARN of the task. The first shows the general format, the second shows a concrete example for starting an AWS CodeBuild build. ```ts { resource: "arn:aws:states:::service:task_type:name" } ``` ```ts { resource: "arn:aws:states:::codebuild:startBuild" } ``` -------------------------------- ### Link resources to a Rust function in sst.config.ts Source: https://sst-community.github.io/sst/docs/reference/sdk Configures an SST function with a Rust runtime and links the `MyBucket` and `OpenaiSecret` resources. This is the setup required for the Rust SDK example to access those resources. ```ts const bucket = new sst.aws.Bucket("MyBucket"); const openai = new sst.Secret("OpenaiSecret"); new sst.aws.Function("MyFunction", { handler: "./", link: [bucket, openai], runtime: "rust" }); ``` -------------------------------- ### StepFunctions.task example Source: https://sst-community.github.io/sst/docs/component/aws/step-functions Creates a Task state that starts an AWS CodeBuild build. The `resource` is the Step Functions service integration ARN, `arguments` are passed to the build, and `permissions` grant the necessary IAM actions. ```ts sst.aws.StepFunctions.task({ name: "Task", resource: "arn:aws:states:::codebuild:startBuild", arguments: { projectName: "my-codebuild-project" }, permissions: [ { actions: ["codebuild:StartBuild"], resources: ["*"] } ] }); ``` -------------------------------- ### Share MySQL database across stages Source: https://sst-community.github.io/sst/docs/component/aws/mysql Example of using the static get method to share a MySQL database across stages. In the 'frank' stage it retrieves the existing database from 'dev', otherwise it creates a new one with a proxy. ```ts const database = $app.stage === "frank" ? sst.aws.Mysql.get("MyDatabase", { id: "app-dev-mydatabase", proxyId: "app-dev-mydatabase-proxy" }) : new sst.aws.Mysql("MyDatabase", { proxy: true }); ``` -------------------------------- ### Share Redis cluster across stages Source: https://sst-community.github.io/sst/docs/component/aws/redis-v1 Example of using the static get method to share a Redis cluster across stages. In the 'frank' stage, it retrieves the existing cluster with ID 'app-dev-myredis' from the 'dev' stage; otherwise, it creates a new one. ```ts const redis = $app.stage === "frank" ? sst.aws.Redis.v1.get("MyRedis", "app-dev-myredis") : new sst.aws.Redis.v1("MyRedis"); ``` -------------------------------- ### Generate pre-signed URL in SvelteKit load function Source: https://sst-community.github.io/sst/docs/start/aws/svelte Creates a SvelteKit server load function that generates a pre-signed URL for uploading to an S3 bucket. The imports and npm install command are required for this setup. The URL is returned to the client for direct upload. ```ts /** @type {import('./$types').PageServerLoad} */ export async function load() { const command = new PutObjectCommand({ Key: crypto.randomUUID(), Bucket: Resource.MyBucket.name, }); const url = await getSignedUrl(new S3Client({}), command); return { url }; } ``` ```ts import { Resource } from "sst"; import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; ``` ```bash npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner ``` -------------------------------- ### Create a Remix app Source: https://sst-community.github.io/sst/docs/start/aws/remix Run these commands to create a new Remix app and navigate into its directory. Select all default options. ```bash npx create-remix@latest aws-remix-container cd aws-remix-container ```