### Install Dependencies and Start Development Server Source: https://sst.dev/docs/examples/aws-jsx-email Install project dependencies and start the SST development server. This will trigger an email verification process. ```bash npm install npx sst dev ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/tan-stack-start Deploy a TanStack Start app located in the project root. ```APIDOC ## new sst.aws.TanStackStart() ### Description Deploys a TanStack Start app. ### Method ```ts new TanStackStart(name: string, args?: TanStackStartArgs, opts?: ComponentResourceOptions) ``` ### Parameters * `name` (string) * `args`? (`TanStackStartArgs`) * `opts`? (`ComponentResourceOptions`) ### Example ```js new sst.aws.TanStackStart("MyWeb"); ``` ``` -------------------------------- ### Full Example: Setup VPC, Cluster, Service, and API Gateway in sst.config.ts Source: https://sst.dev/docs/examples/aws-cluster-vpclink This example demonstrates the complete setup for an AWS Cluster with API Gateway using a VPC link. It includes creating a VPC, a Cluster, a Service, and an API Gateway, then routing traffic from the API Gateway to the service. ```typescript const vpc = new sst.aws.Vpc("MyVpc", { // Pick at least two AZs that support VPC link // az: ["eu-west-3a", "eu-west-3c"], }); const cluster = new sst.aws.Cluster("MyCluster", { vpc }); const service = new sst.aws.Service("MyService", { cluster, serviceRegistry: { port: 80, }, }); const api = new sst.aws.ApiGatewayV2("MyApi", { vpc }); api.routePrivate("$default", service.nodes.cloudmapService.arn); ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/bucket A basic example of creating an S3 bucket. ```APIDOC ## Minimal Example ```ts const bucket = new sst.aws.Bucket("MyBucket"); ``` ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/cloudflare/static-site-v2 This example shows the minimal configuration to upload the current directory as a static site. ```APIDOC ## new sst.cloudflare.StaticSiteV2 ### Description Initializes a new StaticSiteV2 component with a given name. ### Constructor ```ts new StaticSiteV2(name, args?, opts?) ``` #### Parameters - `name` (string) - `args?` (StaticSiteV2Args) - `opts?` (ComponentResourceOptions) ### Request Example ```js new sst.cloudflare.StaticSiteV2("MyWeb"); ``` ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/cloudflare/static-site This example shows the minimal configuration to upload the current directory as a static site. ```APIDOC ## new sst.cloudflare.StaticSite(name, args?, opts?) ### Description Deploys a static website to Cloudflare. ### Parameters - `name` (string) - `args?` (StaticSiteArgs) - `opts?` (ComponentResourceOptions) ### Example ```js new sst.cloudflare.StaticSite("MyWeb"); ``` ``` -------------------------------- ### Python Package Installation Source: https://sst.dev/docs/component/aws/function Install Python packages using uv before starting 'sst dev'. Ensure all necessary packages are synchronized. ```bash uv sync --all-packages ``` -------------------------------- ### Install MQTT Package Source: https://sst.dev/docs/start/aws/realtime Installs the necessary MQTT client package for real-time communication. ```bash npm install mqtt ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/kinesis-stream A minimal example demonstrating how to create a KinesisStream. ```APIDOC ## Minimal Example ```ts title="sst.config.ts" const stream = new sst.aws.KinesisStream("MyStream"); ``` ``` -------------------------------- ### Full AWS Task and Cron Configuration Source: https://sst.dev/docs/examples/aws-task-cron A comprehensive example showing the setup of a VPC, Cluster, Task, and Cron job. This includes linking resources and defining local development commands. Ensure the Docker daemon is running for deployment. ```typescript const bucket = new sst.aws.Bucket("MyBucket"); const vpc = new sst.aws.Vpc("MyVpc"); const cluster = new sst.aws.Cluster("MyCluster", { vpc }); const task = new sst.aws.Task("MyTask", { cluster, link: [bucket], dev: { command: "node index.mjs", }, }); new sst.aws.Cron("MyCron", { task, schedule: "rate(2 minutes)", }); ``` -------------------------------- ### MySQL Example Source: https://sst.dev/docs/component/cloudflare/hyperdrive Example of configuring the Hyperdrive component for a MySQL database. ```APIDOC ## MySQL Example ```ts title="sst.config.ts" const hyperdrive = new sst.cloudflare.Hyperdrive("MySQLDatabase", { origin: { database: "app", host: "db.example.com", password: "secret", scheme: "mysql", user: "root", }, }) ``` ``` -------------------------------- ### Install SST with Bun Source: https://sst.dev/docs Install the SST CLI locally for JavaScript projects using Bun. ```bash bun add sst ``` -------------------------------- ### Install Dependencies Source: https://sst.dev/docs/set-up-a-monorepo Install all project dependencies after cloning the monorepo template. ```bash npm install ``` -------------------------------- ### PostgreSQL Example Source: https://sst.dev/docs/component/cloudflare/hyperdrive Example of configuring the Hyperdrive component for a PostgreSQL database. ```APIDOC ## PostgreSQL Example ```ts title="sst.config.ts" const hyperdrive = new sst.cloudflare.Hyperdrive("PostgresDatabase", { origin: { database: "app", host: "db.example.com", password: "secret", scheme: "postgres", user: "postgres", }, }) ``` ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/step-functions A basic example demonstrating how to create a Step Functions state machine with pass and succeed states. ```APIDOC ## Minimal Example This example shows the basic setup for a Step Functions state machine. ```ts const foo = sst.aws.StepFunctions.pass({ name: "Foo" }); const bar = sst.aws.StepFunctions.succeed({ name: "Bar" }); const definition = foo.next(bar); new sst.aws.StepFunctions("MyStateMachine", { definition }); ``` ``` -------------------------------- ### Install Deno AWS SDK Packages Source: https://sst.dev/docs/start/aws/deno Install the required AWS SDK packages for Deno using the `deno install` command with npm specifiers. ```bash deno install npm:sst npm:@aws-sdk/client-s3 npm:@aws-sdk/lib-storage npm:@aws-sdk/s3-request-presigner ``` -------------------------------- ### Install SST with npm Source: https://sst.dev/docs Install the SST CLI locally for JavaScript projects using npm. ```bash npm install sst ``` -------------------------------- ### Start SST Dev Mode Source: https://sst.dev/docs/start/aws/analog Run this command to start SST in development mode, which also starts your Analog application. Access your app via the provided URL. ```bash npx sst dev ``` -------------------------------- ### Start Local Development Server Source: https://sst.dev/docs/examples/aws-bun-elysia Use this command to start your SST application locally for development. ```bash bun sst dev ``` -------------------------------- ### Create TanStack Start Project Source: https://sst.dev/docs/start/aws/tanstack Use this command to create a new TanStack Start project. Follow the init wizard for project configuration. ```bash npm create @tanstack/start@latest ``` -------------------------------- ### Install SST with pnpm Source: https://sst.dev/docs Install the SST CLI locally for JavaScript projects using pnpm. ```bash pnpm add sst ``` -------------------------------- ### Install Redis and Router Packages Source: https://sst.dev/docs/start/aws/solid Installs the necessary npm packages for connecting to Redis and routing in the SolidStart application. ```bash npm install ioredis @solidjs/router ``` -------------------------------- ### Start Local Development Server Source: https://sst.dev/docs/examples/aws-bun-redis Starts the local development server using the SST CLI. Access the application at http://localhost:3000. ```bash bun sst dev ``` -------------------------------- ### Install SST with Yarn Source: https://sst.dev/docs Install the SST CLI locally for JavaScript projects using Yarn. ```bash yarn add sst ``` -------------------------------- ### Install AWS SDK Packages Source: https://sst.dev/docs/start/aws/analog Install the necessary AWS SDK packages for S3 client and request presigner. ```bash npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner ``` -------------------------------- ### Example SST Configuration Source: https://sst.dev/docs/reference/cli Example of an SST configuration file defining AWS S3 buckets as resources. ```typescript new sst.aws.Bucket("MyMainBucket"); new sst.aws.Bucket("MyAdminBucket"); ``` -------------------------------- ### Install OpenAuth Dependencies Source: https://sst.dev/docs/start/aws/auth Installs the necessary npm packages for OpenAuth, Valibot, and Hono. ```bash npm install @openauthjs/openauth valibot hono ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/solid-start Deploys a SolidStart app located in the project root. ```APIDOC ## new sst.aws.SolidStart(name, args?, opts?) ### Description Deploys a SolidStart application to AWS. ### Parameters - `name` (string): The name of the SolidStart application. - `args?` (SolidStartArgs): Optional arguments for configuring the SolidStart app. - `opts?` (ComponentResourceOptions): Optional options for the component resource. ``` -------------------------------- ### Reference Existing DSQL Cluster (Multi-Region) Source: https://sst.dev/docs/component/aws/dsql Use the `static get` method to reference an existing DSQL cluster, including its peer cluster information for multi-region setups. This allows sharing a cluster across stages. This example configures a multi-region cluster with a peer cluster in a different region. ```typescript const cluster = sst.aws.Dsql.get("MyCluster", { id: "app-dev-mycluster", peer: { id: "kzttrvbdg4k2o5ze2m2rrwdj7u", region: "us-east-2", } }); ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/analog Deploy an Analog app located in the project root. ```APIDOC ## Minimal Example Deploy an Analog app that's in the project root. ```js title="sst.config.ts" new sst.aws.Analog("MyWeb"); ``` ``` -------------------------------- ### Start Local Development Server Source: https://sst.dev/docs/examples/aws-astro-redis Starts the SST local development server. Access your application at http://localhost:4321 to see changes. ```bash npx sst dev ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/cloudflare/astro Deploy an Astro site located in the project root. ```APIDOC ## new sst.cloudflare.Astro("MyWeb") ### Description Deploys an Astro site from the project root. ### Constructor ```ts new Astro(name: string, args?: AstroArgs, opts?: ComponentResourceOptions) ``` ### Parameters - `name` (string) - `args?` (AstroArgs) - `opts?` (ComponentResourceOptions) ``` -------------------------------- ### Install SST Tunnel Source: https://sst.dev/docs/examples/aws-astro-redis Installs the SST tunnel utility, which requires sudo privileges. This is a one-time setup for connecting to VPC resources locally. ```bash sudo npx sst tunnel install ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/svelte-kit Deploy a SvelteKit app located in the project root. ```APIDOC ## Minimal Example Deploy a SvelteKit app that's in the project root. ```js title="sst.config.ts" new sst.aws.SvelteKit("MyWeb"); ``` ``` -------------------------------- ### Install SST Tunnel Source: https://sst.dev/docs/examples/aws-deno-redis Installs the SST tunnel utility, which requires sudo privileges to create a network interface. This is a one-time setup per machine. ```bash sudo sst tunnel install ``` -------------------------------- ### Install AWS SDK Packages for Bun Source: https://sst.dev/docs/start/aws/bun Install the necessary AWS SDK v3 packages for S3 client, storage library, and request presigner. ```bash bun install @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner ``` -------------------------------- ### Minimal Cron Job Example Source: https://sst.dev/docs/component/cloudflare/cron This example demonstrates the basic setup for a Cloudflare Cron job. It requires a worker file with a `scheduled` handler and specifies the cron schedules. ```APIDOC ## Minimal Cron Job Example ### Description This example shows the simplest way to set up a cron job. You need a worker file with a `scheduled` handler and define the `schedules`. ### Worker File (`cron.ts`) ```ts export default { async scheduled() { console.log("Running on a schedule"); }, }; ``` ### SST Config (`sst.config.ts`) ```ts new sst.cloudflare.Cron("MyCronJob", { worker: "cron.ts", schedules: ["* * * * *"] }); ``` ``` -------------------------------- ### Custom Authorizer Setup Source: https://sst.dev/docs/component/aws/apigatewayv1-lambda-route Example of setting up a custom Lambda authorizer for API Gateway. ```javascript const userPool = new aws.cognito.UserPool(); const myAuthorizer = api.addAuthorizer({ name: "MyAuthorizer", userPools: [userPool.arn] }); ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/astro Deploys an Astro site located in the project root. ```APIDOC ## Constructor ```ts new Astro(name, args?, opts?) ``` ### Parameters - `name` `string` - `args?` [`AstroArgs`](#astroargs) - `opts?` [`ComponentResourceOptions`](https://www.pulumi.com/docs/concepts/options/) ### Example ```js title="sst.config.ts" new sst.aws.Astro("MyWeb"); ``` ``` -------------------------------- ### Cognito Authorizer Setup Source: https://sst.dev/docs/component/aws/apigatewayv1-lambda-route Example of setting up a Cognito User Pool authorizer for API Gateway. ```javascript const userPool = new aws.cognito.UserPool(); const myAuthorizer = api.addAuthorizer({ name: "MyAuthorizer", userPools: [userPool.arn] }); ``` -------------------------------- ### Initialize Deno Project Source: https://sst.dev/docs/start/aws/deno Use this command to create a new Deno project. ```bash deno init aws-deno ``` -------------------------------- ### Customize Autodeploy Workflow Source: https://sst.dev/docs/reference/config Define a custom build workflow for autodeploy using shell commands. This example installs pnpm, installs dependencies, and then deploys or removes the application based on the Git event action. ```typescript { autodeploy: { async workflow({ $, event }) { await $`npm i -g pnpm`; await $`pnpm i`; event.action === "removed" ? await $`pnpm sst remove` : await $`pnpm sst deploy`; } } } ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/react Deploy a React app located in the project root. ```APIDOC ## new sst.aws.React("MyWeb") ### Description Deploys a React application from the project root. ### Method Constructor ### Parameters - `name` (string) - The name of the React application resource. ### Request Example ```js new sst.aws.React("MyWeb"); ``` ``` -------------------------------- ### Minimal KV Storage Example Source: https://sst.dev/docs/component/cloudflare/kv Add a Cloudflare KV storage namespace to your app. This is the most basic setup. ```typescript const storage = new sst.cloudflare.Kv("MyStorage"); ``` -------------------------------- ### Configure Shared ALB in sst.config.ts Source: https://sst.dev/docs/examples/aws-shared-alb-static Use the `$dev ? get : new` pattern to conditionally get an existing VPC, Cluster, and ALB in development or create new ones. This setup allows sharing the ALB across stages. ```typescript const vpc = $dev ? sst.aws.Vpc.get("MyVpc", "vpc-xxx") : new sst.aws.Vpc("MyVpc"); const cluster = $dev ? sst.aws.Cluster.get("MyCluster", { id: "cluster-xxx", vpc }) : new sst.aws.Cluster("MyCluster", { vpc }); const alb = $dev ? sst.aws.Alb.get("SharedAlb", "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/xxx") : new sst.aws.Alb("SharedAlb", { vpc, listeners: [ { port: 80, protocol: "http" }, ], }); if ($dev) { new sst.aws.Service("Web", { cluster, image: { context: "web/" }, loadBalancer: { instance: alb, rules: [ { listen: "80/http", forward: "3000/http", conditions: { path: "/app/*" }, priority: 200, }, ], }, }); } new sst.aws.Service("Api", { cluster, image: { context: "api/" }, loadBalancer: { instance: alb, rules: [ { listen: "80/http", forward: "3000/http", conditions: { path: "/api/*" }, priority: 100, }, ], }, }); ``` -------------------------------- ### Create and Initialize Bun Project Source: https://sst.dev/docs/start/aws/bun Use these commands to create a new directory, navigate into it, and initialize a new Bun project. ```bash mkdir aws-bun && cd aws-bun bun init -y ``` -------------------------------- ### Initialize Project and SST Source: https://sst.dev/docs/start/cloudflare/worker Create a new project directory, initialize it with npm, and then initialize SST, selecting Cloudflare as the target environment. Install project dependencies. ```bash mkdir my-worker && cd my-worker npm init -y npx sst@latest init npm install ``` -------------------------------- ### Default Workflow with pnpm Source: https://sst.dev/docs/reference/config An example of the default build workflow customized for pnpm. It installs dependencies and deploys or removes the app based on the git event. ```typescript { async workflow({ $, event }) { await $`npm i -g pnpm`; await $`pnpm i`; event.action === "removed" ? await $`pnpm sst remove` : await $`pnpm sst deploy`; } } ``` -------------------------------- ### Minimal Python Function Source: https://sst.dev/docs/component/aws/function Basic setup for a Python Lambda function, specifying runtime and handler. Requires uv installation and a uv workspace for the handler. ```typescript new sst.aws.Function("MyFunction", { runtime: "python3.13", handler: "functions/src/functions/api.handler" }); ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/remix Deploy a Remix app located in the project root. ```APIDOC ## Minimal Example Deploy a Remix app that's in the project root. ```ts title="sst.config.ts" new sst.aws.Remix("MyWeb"); ``` ``` -------------------------------- ### Add the Stripe provider Source: https://sst.dev/docs/all-providers Example of adding the Stripe provider using the `sst add` command. This command handles the necessary setup for using Stripe resources. ```bash sst add stripe ``` -------------------------------- ### Full SST Configuration Example Source: https://sst.dev/docs/configure-a-router This is the complete SST configuration file, demonstrating how to set up permanent stages, domain helpers, routers, and various components like Next.js frontend, API functions, and Astro docs. ```typescript const isPermanentStage = ["production", "dev"].includes($app.stage); const domain = $app.stage === "production" ? "example.com" : $app.stage === "dev" ? "dev.example.com" : `${$app.stage}.dev.example.com`; function subdomain(name: string) { if (isPermanentStage) return `${name}.${domain}`; return `${name}-${domain}`; } const router = isPermanentStage ? new sst.aws.Router("MyRouter", { domain: { name: domain, aliases: [`*.${domain}`] } }) : sst.aws.Router.get("MyRouter", "A2WQRGCYGTFB7Z"); // Frontend const web = new sst.aws.Nextjs("MyWeb", { path: "packages/web", router: { instance: router } }); // API const api = new sst.aws.Function("MyApi", { handler: "packages/functions/api.handler", url: { router: { instance: router, path: "/api" } } }); // Docs const docs = new sst.aws.Astro("MyDocs", { path: "packages/docs", router: { instance: router, domain: subdomain("docs") } }); ``` -------------------------------- ### WaitArgs time example Source: https://sst.dev/docs/component/aws/step-functions/wait Use the `time` argument to specify the duration to wait before starting the next state. This can be a string representing a duration or a JSONata expression evaluating to seconds. ```typescript { time: "10 seconds" } ``` ```typescript { time: "{% $states.input.wait_time %}" } ``` -------------------------------- ### Create a new project directory Source: https://sst.dev/docs/start/cloudflare/trpc Initializes a new project directory and navigates into it. ```bash mkdir my-trpc-app && cd my-trpc-app npm init -y ``` -------------------------------- ### Issuer function for Auth Source: https://sst.dev/docs/component/aws/auth Example of an issuer function using Hono and OpenAuth. This function sets up authentication providers and handles success callbacks. Ensure you have the necessary OpenAuth and Hono packages installed. ```typescript import { handle } from "hono/aws-lambda"; import { issuer } from "@openauthjs/openauth"; import { CodeProvider } from "@openauthjs/openauth/provider/code"; import { subjects } from "./subjects"; const app = issuer({ subjects, providers: { code: CodeProvider() }, success: async (ctx, value) => {} }); export const handler = handle(app); ``` -------------------------------- ### Configure Allowed Methods for Lambda Function URL CORS Source: https://sst.dev/docs/component/aws/function Sets the allowed HTTP methods for a Lambda Function URL's CORS configuration. This example restricts methods to GET, POST, and DELETE. ```js { url: { cors: { allowMethods: ["GET", "POST", "DELETE"] } } } ``` -------------------------------- ### Initialize Project and SST Source: https://sst.dev/docs/start/aws/trpc Create a new project directory and initialize it with npm, then initialize SST within the project. ```bash mkdir my-trpc-app && cd my-trpc-app npm init -y npx sst@latest init npm install ``` -------------------------------- ### API Handler for Database Operations Source: https://sst.dev/docs/examples/aws-dsql-drizzle Implement API handlers for GET and POST requests to interact with the Drizzle ORM and the Aurora DSQL database. This example includes fetching all todos and inserting a new todo. ```typescript import { db } from "./drizzle"; import { todo } from "./todo.sql"; import { APIGatewayProxyEventV2 } from "aws-lambda"; export const handler = async (evt: APIGatewayProxyEventV2) => { if (evt.requestContext.http.method === "GET") { const result = await db.select().from(todo).execute(); return { statusCode: 200, body: JSON.stringify(result, null, 2), }; } if (evt.requestContext.http.method === "POST") { const result = await db .insert(todo) .values({ title: "Todo", description: crypto.randomUUID() }) .returning() .execute(); return { statusCode: 200, body: JSON.stringify(result), }; } }; ``` -------------------------------- ### Create and Initialize Express App Source: https://sst.dev/docs/start/aws/express Sets up a new Node.js project, installs Express, and creates a basic Express server listening on port 80. ```bash mkdir aws-express && cd aws-express npm init -y npm install express ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/cloudflare/react-router Deploy a React Router app located in the project root. ```APIDOC ## new sst.cloudflare.ReactRouter("MyWeb") ### Description Deploys the React Router app that's in the project root. ### Method ```ts new ReactRouter(name: string, args?: ReactRouterArgs, opts?: ComponentResourceOptions) ``` ### Parameters #### name - `name` (string) - The name of the React Router application. #### args - `args` (ReactRouterArgs) - Optional configuration for the React Router app. - `path` (string) - The path to the React Router app directory. Defaults to the project root. - `domain` (string | { name: string, redirects?: string[], aliases?: string[] }) - The custom domain for the React Router app. - `link` (Array) - Resources to link to the React Router app. - `buildCommand` (string) - The command used internally to build your React Router app. Defaults to "npm run build". - `dev` (false | Object) - Configure how this component works in `sst dev`. - `autostart` (boolean) - Configure if you want to automatically start this when `sst dev` starts. Defaults to `true`. - `command` (string) - The command that `sst dev` runs to start this in dev mode. Defaults to "npm run dev". - `directory` (string) - Change the directory from where the `command` is run. Defaults to the `path`. - `title` (string) - The title of the tab in the multiplexer. - `url` (string) - The `url` when this is running in dev mode. Defaults to "http://url-unavailable-in-dev.mode". #### opts - `opts` (ComponentResourceOptions) - Options for the component resource. ``` -------------------------------- ### Define a generic Task state for AWS CodeBuild Source: https://sst.dev/docs/component/aws/step-functions Use the `sst.aws.StepFunctions.task` method to create a generic Task state for AWS Step Functions. This example shows how to configure it to start an AWS CodeBuild build. Ensure you have the necessary permissions defined. ```typescript sst.aws.StepFunctions.task({ name: "Task", resource: "arn:aws:states:::codebuild:startBuild", arguments: { projectName: "my-codebuild-project" }, permissions: [ { actions: ["codebuild:StartBuild"], resources: ["*"] } ] }); ``` -------------------------------- ### Running Vite Dev Server Locally Source: https://sst.dev/docs/component/aws/static-site Example command to run a Vite development server locally using `sst dev`. This command starts the Vite dev server and passes environment variables from the SST config, but does not deploy the site to AWS. ```bash sst dev vite dev ``` -------------------------------- ### Minimal Example Source: https://sst.dev/docs/component/aws/nextjs Deploy the Next.js app located in the project root. ```APIDOC ## Minimal Example Deploy the Next.js app that's in the project root. ```js title="sst.config.ts" new sst.aws.Nextjs("MyWeb"); ``` ``` -------------------------------- ### Reference Existing DSQL Cluster (Single-Region) Source: https://sst.dev/docs/component/aws/dsql Use the `static get` method to reference an existing DSQL cluster by its ID. This is useful for sharing a cluster across stages without creating a new one. This example shows a single-region cluster configuration. ```typescript const cluster = $app.stage === "frank" ? sst.aws.Dsql.get("MyCluster", { id: "kzttrvbdg4k2o5ze2m2rrwdj7u" }) : new sst.aws.Dsql("MyCluster"); ``` -------------------------------- ### Initialize Project with SST Source: https://sst.dev/docs/examples/aws-bun-elysia Run these commands to create a new Bun Elysia project and initialize it with SST. ```bash bun create elysia aws-bun-elysia cd aws-bun-elysia bunx sst init ``` -------------------------------- ### AWS Lambda Handler with Drizzle ORM Source: https://sst.dev/docs/examples/aws-planetscale-drizzle-postgres An example AWS Lambda handler function that uses Drizzle ORM to interact with a PlanetScale Postgres database. It supports GET requests to fetch todos and POST requests to create a new todo. Ensure the `todosTable` schema is defined elsewhere. ```typescript import { db } from "./drizzle"; import { todosTable } from "./schema"; import { APIGatewayProxyHandlerV2 } from "aws-lambda"; export const handler: APIGatewayProxyHandlerV2 = async (evt) => { if (evt.requestContext.http.method === "GET") { const result = await db.select().from(todosTable).execute(); return { statusCode: 200, body: JSON.stringify(result), }; } if (evt.requestContext.http.method === "POST") { await db.insert(todosTable).values({ title: "new todosTable" }).execute(); return { statusCode: 200, body: "created", }; } return { statusCode: 404, body: "not found", }; }; ``` -------------------------------- ### Initialize New SST Project Source: https://sst.dev/docs/reference/cli Initialize a new SST project in the current directory, creating `sst.config.ts` and installing providers. ```bash sst init ``` -------------------------------- ### Create SolidStart Project Source: https://sst.dev/docs/start/aws/solid Initializes a new SolidStart project with basic configuration. Selects SolidStart, basic template, and TypeScript. ```bash npm init solid@latest aws-solid-container cd aws-solid-container ``` -------------------------------- ### Install Specific Version of SST CLI Source: https://sst.dev/docs/reference/cli Install a specific version of the SST CLI by setting the VERSION environment variable during global installation. ```bash curl -fsSL https://sst.dev/install | VERSION=0.0.403 bash ``` -------------------------------- ### Create a new project directory Source: https://sst.dev/docs/start/cloudflare/hono Initializes a new project directory and npm. ```bash mkdir my-hono-api && cd my-hono-api npm init -y ``` -------------------------------- ### Install TypeScript Source: https://sst.dev/docs/examples/aws-hono-redis Installs TypeScript as a development dependency in the project. ```bash npm install typescript --save-dev ``` -------------------------------- ### Minimal StaticSiteV2 Example Source: https://sst.dev/docs/component/cloudflare/static-site-v2 Uploads the current directory as a static site. ```javascript new sst.cloudflare.StaticSiteV2("MyWeb"); ``` -------------------------------- ### Create Astro Project Source: https://sst.dev/docs/start/aws/astro Initialize a new Astro project with the default options. Navigate into the project directory after creation. ```bash npm create astro@latest aws-astro-container cd aws-astro-container ``` -------------------------------- ### Initialize SST Project Source: https://sst.dev/docs/start/aws/email Initialize a new SST project in your application directory. This sets up the necessary configuration files for SST. ```bash mkdir my-email-app && cd my-email-app npm init -y npx sst@latest init npm install ``` -------------------------------- ### Create a new Node.js project Source: https://sst.dev/docs/start/aws/drizzle Initializes a new Node.js project directory and navigates into it. ```bash mkdir aws-drizzle && cd aws-drizzle npm init -y ``` -------------------------------- ### Initialize Express App Source: https://sst.dev/docs/start/aws/prisma Sets up a basic Express server that listens on port 80 and responds with 'Hello World!'. ```js import express from "express"; const PORT = 80; const app = express(); app.get("/", (req, res) => { res.send("Hello World!") }); app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); }); ``` -------------------------------- ### Install Hono npm package Source: https://sst.dev/docs/start/cloudflare/hono Installs the Hono framework as a project dependency. ```bash npm install hono ``` -------------------------------- ### Install tRPC Client Dependency Source: https://sst.dev/docs/start/aws/trpc Install the tRPC client npm package. ```bash npm install @trpc/client@next ``` -------------------------------- ### static get Source: https://sst.dev/docs/component/aws/cognito-user-pool Get an existing Cognito User Pool by name and ID. ```APIDOC ## static get ### Description Get an existing Cognito User Pool by name and ID. ### Signature `CognitoUserPool.get(name: string, userPoolID: string, opts?: ComponentResourceOptions): CognitoUserPool` ### Parameters - `name` (`string`): The name of the User Pool. - `userPoolID` (`string`): The ID of the User Pool. - `opts?` (`ComponentResourceOptions`): Resource options. ``` -------------------------------- ### Create a MySQL Database Source: https://sst.dev/docs/component/aws/mysql Example of creating a new MySQL database instance and linking it to a VPC. ```APIDOC ## Create a MySQL Database ### Description This snippet shows how to instantiate the `sst.aws.Mysql` component to create a new MySQL database. ### Code ```ts import * as sst from "sst"; const vpc = new sst.aws.Vpc("MyVpc"); const database = new sst.aws.Mysql("MyDatabase", { vpc }); ``` ``` -------------------------------- ### Create SolidStart Project Source: https://sst.dev/docs/start/aws/solid Initializes a new SolidStart project with TypeScript. Ensure you select the 'SolidStart', 'basic', and 'TypeScript' options. ```bash npm init solid@latest aws-solid-start cd aws-solid-start ``` -------------------------------- ### Install SST Rust SDK Source: https://sst.dev/docs/reference/sdk Install the SST Rust SDK using cargo. ```bash cargo install sst_sdk ``` -------------------------------- ### Full SST Stack Configuration with Prisma Source: https://sst.dev/docs/examples/aws-prisma-lambda This example shows a complete SST stack configuration including VPC, RDS instance, and a Lambda function linked to the database. It demonstrates how to integrate Prisma by setting the VPC, copying client files, and optionally configuring the ARM architecture. ```typescript const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); const rds = new sst.aws.Postgres("MyPostgres", { vpc }); const api = new sst.aws.Function("MyApi", { vpc, url: true, link: [rds], // For ARM // architecture: "arm64", handler: "index.handler", copyFiles: [{ from: "node_modules/.prisma/client/" }], }); ``` -------------------------------- ### Create and configure an EFS file system Source: https://sst.dev/docs/component/aws/task Demonstrates how to create an EFS file system using the SST Efs component and then mount it into a task volume. This is useful for persistent storage needs. ```typescript const vpc = new sst.aws.Vpc("MyVpc"); const fileSystem = new sst.aws.Efs("MyFileSystem", { vpc }); ``` -------------------------------- ### Creating a Postgres Database Source: https://sst.dev/docs/component/aws/postgres Example of how to create a new Postgres database instance within your SST application. ```APIDOC ## Create Postgres Database ### Description Instantiates a new AWS RDS Postgres database. ### Method `new sst.aws.Postgres(name, args)` ### Parameters - `name` (string): The name of the Postgres instance. - `args` (PostgresArgs): Configuration options for the Postgres database. ### Example ```js const vpc = new sst.aws.Vpc("MyVpc"); const database = new sst.aws.Postgres("MyDatabase", { vpc }); ``` ``` -------------------------------- ### Configure S3 Client and PresignedClient in Go Source: https://sst.dev/docs/examples/aws-go-lambda-bucket-presigned-url Load default AWS configuration and create S3 and Presigned clients. Ensure AWS credentials and region are configured. ```go cfg, err := config.LoadDefaultConfig(context.TODO()) if err != nil { panic(err) } client := s3.NewFromConfig(cfg) presignedClient := s3.NewPresignClient(client) ``` -------------------------------- ### Initialize a new SST app Source: https://sst.dev/docs/basics Run this command to create a new SST application. It sets up the basic project structure and configuration. ```bash sst init ``` -------------------------------- ### Get Global Help Source: https://sst.dev/docs/reference/cli Display global help information for the SST CLI. ```bash sst --help ``` -------------------------------- ### QueryEvent Count Example Source: https://sst.dev/docs/component/aws/vector Example of setting the count for a QueryEvent to specify the number of results to return. ```javascript { count: 10 } ``` -------------------------------- ### SNS Topic Message Example Source: https://sst.dev/docs/component/aws/sns-topic An example of a JSON message that might be sent to an SNS Topic. ```json { "store": "example_corp", "event": "order-placed", "customer_interests": [ "soccer", "rugby", "hockey" ], "price_usd": 210.75 } ``` -------------------------------- ### Project Structure Example Source: https://sst.dev/docs/examples/aws-python-container This shows a typical project structure when using custom Dockerfiles for Lambda functions. ```text ├── sst.config.ts ├── pyproject.toml └── custom_dockerfile ├── pyproject.toml ├── Dockerfile └── src └── custom_dockerfile └── api.py ``` -------------------------------- ### Create a new Node.js project Source: https://sst.dev/docs/start/aws/prisma Initializes a new Node.js project and installs necessary dependencies for Prisma, TypeScript, and Express. ```bash mkdir aws-prisma && cd aws-prisma npm init -y npm install prisma typescript ts-node @types/node --save-dev npm install express npx tsc --init npx prisma init ``` -------------------------------- ### Create a Next.js app Source: https://sst.dev/docs/start/aws/realtime Initialize a new Next.js project. This is the first step before integrating SST. ```bash npx create-next-app@latest my-realtime-app cd my-realtime-app ``` -------------------------------- ### Example Event Structure Source: https://sst.dev/docs/component/aws/bus This is an example of an EventBridge message structure. It includes source, detail, and detail-type attributes. ```json { source: "my.source", detail: { price_usd: 210.75 }, "detail-type": "orderPlaced" } ``` -------------------------------- ### ApiGatewayV1ApiKey Args Example Source: https://sst.dev/docs/component/aws/apigatewayv1-api-key Example of arguments for creating an API key, including an optional pre-defined value. ```javascript { value: "d41d8cd98f00b204e9800998ecf8427e" } ``` -------------------------------- ### Install ioredis Package Source: https://sst.dev/docs/start/aws/nuxt Install the ioredis npm package to enable connection to your Redis cluster from your Nuxt application. ```bash npm install ioredis ```