Deploy Solid Start on AWS
Deploy your Solid Start applications to AWS using Thunder patterns. This guide covers static site generation and full-stack server-side rendering options.
There are two deployment patterns available for Solid Start on AWS:
- Static Site Generation (SSG) — Deploy static Solid Start sites using S3 and CloudFront with the
Staticconstruct - Full Stack — Deploy SSR Solid Start applications using ECS Fargate with the
Fargateconstruct
Static Site Generation (SSG) Deployment
Deploy static Solid Start applications to S3 and CloudFront using the Static construct. This pattern is ideal for static sites, blogs, and client-side applications.
Create Project
npm create solid@latest my-solid-appcd my-solid-apppnpm create solid my-solid-appcd my-solid-appbun create solid my-solid-appcd my-solid-appConfigure Solid Start for SSG
Configure your app for static site generation using the static preset:
import { defineConfig } from '@solidjs/start/config';
export default defineConfig({ server: { preset: 'static' }});Install Dependencies and Setup Stack
npm i tsx @thunder-so/thunder --save-devpnpm add -D tsx @thunder-so/thunderbun add -d tsx @thunder-so/thunderimport { Cdk, Static, type StaticProps } from "@thunder-so/thunder";
const myApp: StaticProps = { env: { account: 'your-account-id', region: 'us-east-1' }, application: 'your-application-id', service: 'your-service-id', environment: 'production',
rootDir: '', // e.g. 'frontend' for monorepos outputDir: 'dist',};
new Static( new Cdk.App(), `${myApp.application}-${myApp.service}-${myApp.environment}-stack`, myApp);Deploy
Build and deploy your static Solid Start site:
npm run buildnpx cdk deploy --all --app="npx tsx stack/index.ts"pnpm run buildpnpm exec cdk deploy --all --app="pnpm exec tsx stack/index.ts"bun run buildnpx cdk deploy --all --app="bunx tsx stack/index.ts"After deployment, you’ll receive a CloudFront URL to access your static site.
Full Stack Deployment
Deploy server-side rendered Solid Start applications using ECS Fargate and Application Load Balancer with the Fargate construct.
Install Dependencies and Setup Stack
npm i tsx @thunder-so/thunder --save-devpnpm add -D tsx @thunder-so/thunderbun add -d tsx @thunder-so/thunderimport { Cdk, Fargate, type FargateProps } from "@thunder-so/thunder";
const svcProps: FargateProps = { env: { account: 'your-account-id', region: 'us-west-2' }, application: 'your-application-id', service: 'your-service-id', environment: 'production',
rootDir: '', // e.g. 'app' for monorepos};
new Fargate( new Cdk.App(), `${svcProps.application}-${svcProps.service}-${svcProps.environment}-stack`, svcProps);Build Settings Using Nixpacks
Configure automatic containerization with Nixpacks:
const svcProps: FargateProps = { // ... other props
buildProps: { buildSystem: 'Nixpacks', installcmd: 'npm install', buildcmd: 'npm run build', startcmd: 'npm run start', },};Build Settings Using Docker Container
Alternatively, use a custom Dockerfile:
FROM public.ecr.aws/docker/library/node:20-alpine AS base
FROM base AS builderWORKDIR /app
COPY package*.json ./RUN npm ci
COPY . .RUN npm run build
FROM base AS runnerWORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "./dist/server.js"]const svcProps: FargateProps = { // ... other props
serviceProps: { dockerFile: 'Dockerfile', port: 3000, },};Environment Variables and Secrets for SSR
Configure runtime environment variables and secrets:
const svcProps: FargateProps = { // ... other props
serviceProps: { variables: [ { NODE_ENV: 'production' }, { PUBLIC_API_URL: 'https://api.example.com' } ], secrets: [ { key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-west-2:123456789012:secret:/my-app/DATABASE_URL-abc123' }, ], },};Deploy
Build and deploy your containerized application:
npm run buildnpx cdk deploy --all --app="npx tsx stack/index.ts"pnpm run buildpnpm exec cdk deploy --all --app="pnpm exec tsx stack/index.ts"bun run buildnpx cdk deploy --all --app="bunx tsx stack/index.ts"After deployment, you’ll receive an Application Load Balancer URL to access your SSR application.