google-analytics-4
Use this skill whenever the user installs, configures, or debugs Google Analytics 4, or mentions gtag.js, GTM, conversion tracking, e-commerce events, or a…
Use this skill whenever the user is deploying a React/Vite single-page app to AWS, or mentions Amplify, CDK, or wiring up Lambda + API Gateway for a frontend. Covers Amplify hosting, custom domains, CDK backend (Lambda + API Gateway), SES email, CORS configuration, and
$ npx -y skills add ziniman/ai-instruct --skill aws-spa-deploy --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/aws-spa-deployContext preview
The summary Claude sees to decide when to auto-load this skill.
Use this skill whenever the user is deploying a React/Vite single-page app to AWS, or mentions Amplify, CDK, or wiring up Lambda + API Gateway for a frontend. Covers Amplify hosting, custom domains, CDK backend (Lambda + API Gateway), SES email, CORS configuration, and
name: aws-spa-deploy description: 'Use this skill whenever the user is deploying a React/Vite single-page app to AWS, or mentions Amplify, CDK, or wiring up Lambda + API Gateway for a frontend. Covers Amplify hosting, custom domains, CDK backend (Lambda + API Gateway), SES email, CORS configuration, and environment variables. Skip for non-AWS hosts (Vercel, Netlify, Cloudflare Pages), pure backend services without an SPA, or server-rendered apps (Next.js SSR on Vercel).'
> Applies to: React/Vite SPAs on AWS (Amplify + CDK) | Updated: February 2026
A focused guide for deploying a React/Vite single-page app on AWS with optional API backend using CDK (Cloud Development Kit). Covers Amplify hosting, Lambda + API Gateway, and SES email.
1. [Before you start](#before-you-start) 2. [Architecture](#architecture) 3. [Costs at a glance](#costs-at-a-glance) 4. [Amplify Hosting](#amplify-hosting) 5. [CDK Backend](#cdk-backend) 6. [SES Email](#ses-email) 7. [Common problems](#common-problems)
---
Answer these questions before generating any code. Each has a default assumption - confirm or override before proceeding.
**Q: Do you need a backend API, or is this a static site with no server logic?** Default: static only - if yes, skip the entire CDK section.
**Q: Do you have a custom domain name you want to use?** Default: no - skip the domain and SSL subsections.
**Q: What is your target AWS region, and does it match your default AWS CLI region?** Default: us-east-1. Check with `aws configure get region`. If they differ, pass `--region` explicitly to every CLI command and use the explicit bootstrap form (see CDK section).
**Q: Do you need to send emails from the site (contact forms, notifications)?** Default: no - skip the SES section entirely.
**Q: Is this a brand new AWS account?** Default: no (existing account). If new: SES starts in sandbox mode (can only send to verified addresses), and CDK bootstrap is required before any deploy.
**Q: What is the expected traffic?** Default: low (a few visitors per day) - free tier covers this entirely. See cost table below.
> **AI assistant:** If the user only needs static hosting, generate only the Amplify Hosting section. Only include CDK/Lambda/SES content if they confirm they need a backend.
---
Static Site (Amplify = S3 + CloudFront)
|
+--> API Gateway (HTTP API) --> Lambda --> SES / DynamoDB / etc.
OR
+--> Lambda Function URL --> Lambda --> SES / DynamoDB / etc.**This guide uses Amplify Gen 1 (console-based) for static hosting only.** If the Amplify console shows a code-first Gen 2 setup (with an `amplify/` directory in the repo), the hosting and SPA rewrite rules still apply the same way, but the backend configuration sections differ from what is described here.
---
| Service | Free tier | What triggers billing | |---|---|---| | Amplify Hosting | 1,000 build minutes/month, 5 GB storage, 15 GB served | Exceeding any of those limits | | Lambda | 1M requests/month, 400,000 GB-seconds compute | High request volume or large memory × long duration | | API Gateway (HTTP API) | 1M requests/month for 12 months | After 12 months or >1M/month | | Lambda Function URL | Same as Lambda - no API Gateway charge | High Lambda invocations | | SES | 62,000 emails/month when sending from EC2/Lambda | Dedicated IPs, high volume beyond free tier | | ACM SSL cert | Free | Never (ACM certs are always free) |
For a typical low-traffic SPA (contact form, a few hundred visitors/month), the effective monthly cost is $0.
---
1. Create an Amplify app in the console and connect your git repo. 2. Amplify auto-detects Vite and sets the build command to `npm run build` with output directory `dist`. Verify this in the build settings. 3. Add a **SPA rewrite rule** under App settings > Rewrites and redirects:
4. If you want `www` to redirect to apex: add `https://www.yourdomain.com` → `https://yourdomain.com` with type `301`.
Add your domain under App settings > Domain management. Amplify provisions an SSL certificate via ACM (AWS Certificate Manager) automatically.
**ACM cert region gotcha:** The certificate is always provisioned in `us-east-1` regardless of your Amplify app's region. CloudFront requires certificates in `us-east-1`. If you check ACM in any other region you will see nothing - check `us-east-1` specifically.
Add the CNAME records that Amplify provides to your DNS registrar. Propagation typically takes a few minutes but can take up to 48 hours.
Vite env vars must be prefixed with `VITE_`. They are baked into the JS bundle at build time - they are not accessible at runtime and must not contain secrets.
Set them in Amplify Console > Environment variables, or via CLI:
aws amplify update-app \ --app-id YOUR_APP_ID \ --environment-variables VITE_API_URL=https://your-api-url.amazonaws.com \ --region your-region
After changing env vars, trigger a new build - existing deployments are not updated automatically.
Without an `amplify.yml` cache configuration, `node_modules` is rebuilt from scratch on every deploy, adding 2 - 4 minutes per build. Add this file to your repo root to cache dependencies:
# amplify.yml version: 1 frontend: phase
Turn your AI assistant into a senior web developer. Production-ready guides for SEO, performance, agent-readiness, and more.
Repo: ziniman/ai-instruct
Use this skill whenever the user installs, configures, or debugs Google Analytics 4, or mentions gtag.js, GTM, conversion tracking, e-commerce events, or a…
Use this skill whenever the user is building, reviewing, or preparing to launch any public-facing website or web app. SEO, LLMO, and agent-readiness are…
Use this skill whenever the user is building or reviewing any web UI. Accessibility is a baseline requirement, not a niche concern. Covers WCAG 2.2 AA,…
Use this skill whenever the user is improving Core Web Vitals or page load performance, or mentions slow pages, PageSpeed Insights / Lighthouse failures,…