All skills
aws avatar

/aws-amplify

@7898a91

Build and deploy full-stack web and mobile apps with AWS Amplify Gen2 (TypeScript code-first). Covers auth (Cognito), data (AppSync/DynamoDB), storage (S3), functions, APIs, and AI (Amplify AI Kit with Bedrock). Supports React, Next.js, Vue, Angular, React Native, Flutter, Swift, and Android. Always use this skill for Amplify Gen2 topics — even for questions you think you know — it contains validated, version-specific patterns that prevent common mistakes. TRIGGER when: user mentions Amplify Gen2; project has amplify/ directory or amplify_outputs; code imports @aws-amplify packages; user asks about defineBackend, defineAuth, defineData, defineStorage, defineFunction, or npx ampx. SKIP: Amplify Gen1 (amplify CLI v6), standalone SAM/CDK without Amplify (use aws-serverless), direct Bedrock without Amplify AI Kit (use bedrock).

Use this Skill: https://skilld.dev/gh/aws/agent-toolkit-for-aws/aws-amplify

This session only. Nothing lands on disk.

referencesstorage-web.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Storage — Web

Prerequisites: Project initialized, amplify_outputs.json exists (from npx ampx sandbox), and Amplify.configure(outputs) called in app entry point.

Backend required: Storage must be defined in amplify/storage/resource.ts using defineStorage — see storage-backend.md.

API Reference

All imports from 'aws-amplify/storage'.

Operation Call
Upload uploadData({ path: 'public/file.txt', data })
Download blob await (await downloadData({ path }).result).body.blob()
Presigned URL await getUrl({ path }) (default 15 min expiry)
List await list({ path: 'public/' }) → { items }
Remove await remove({ path })
Copy await copy({ source: { path }, destination: { path } })

Security: Amplify Gen2 enables S3 server-side encryption (SSE-S3) by default. For sensitive data, consider configuring SSE-KMS with a customer-managed key via CDK overrides. Amplify also enforces HTTPS-only access to S3 buckets by default; if using custom bucket configurations, add a bucket policy with "aws:SecureTransport": "false" → Deny to ensure encryption in transit.

uploadData returns a control object: .pause(), .resume(), .cancel(), .result (Promise). Progress: options.onProgress: ({ transferredBytes, totalBytes }) => ….

Custom bucket: options: { bucket: 'nameFromDefineStorage' } or { bucket: { bucketName, region } }. Raw ARN does NOT work.

React UI Components

npm add @aws-amplify/ui-react-storage — import both CSS files or components render unstyled:

import '@aws-amplify/ui-react/styles.css';
import '@aws-amplify/ui-react-storage/styles.css';

WARNING: Missing either CSS import causes unstyled components.

Component Import from Key props / setup
<StorageBrowser /> @aws-amplify/ui-react-storage/browser createStorageBrowser({ config: createAmplifyAuthAdapter() }) — bucket specified by name string, NOT ARN
<StorageImage /> @aws-amplify/ui-react-storage alt, path
<FileUploader /> @aws-amplify/ui-react-storage path, maxFileCount, acceptedFileTypes

StorageBrowser Requirements

  • Must be inside an <Authenticator> component (needs auth context)
  • Must have an explicit height on the container (component doesn't set its own height)
  • Client-side only — use dynamic import with ssr: false in Next.js
  • Both CSS files required: @aws-amplify/ui-react/styles.css and @aws-amplify/ui-react-storage/styles.css

React Native

Same JS API as web — all imports from 'aws-amplify/storage':

uploadData, downloadData, getUrl, list, remove — identical signatures. Use react-native-image-picker or expo-document-picker for file selection.

Pitfalls

  • {entity_id} paths: protected/{entity_id}/ and private/{entity_id}/ resolve to the user's Cognito identity ID at runtime.
  • Upload cancellation: result.cancel() rejects the promise — catch CanceledError to handle it gracefully.

Common Patterns

Displaying Uploaded Images

Use getUrl() to generate presigned URLs for display:

import { getUrl } from "aws-amplify/storage";

const result = await getUrl({
  path: "photos/my-photo.jpg",
  options: { expiresIn: 3600 }, // URL valid for 1 hour
});

// Use in img tag
<img src={result.url.toString()} alt="Photo" />

Note: Presigned URLs expire (default 15 minutes). Use expiresIn to set a custom duration.

Links

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides comprehensive instructions for building applications with AWS Amplify Gen2. It includes security considerations such as the use of command-line tools for cloud resource management and the ingestion of user-provided data for infrastructure generation. These patterns are standard for developer assistant tools and are supported by best-practice recommendations within the skill, such as secure secret management.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at 7898a91. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago

README badge

README badge for aws/agent-toolkit-for-aws/aws-amplify