/sveltekit-adapter-aws

🔌 SveleteKit AWS adapter with multiple architecture

Primary LanguageTypeScriptMIT LicenseMIT

@jill64/sveltekit-adapter-aws

npm-version npm-license npm-download-month npm-min-size deploy-test-buffered.yml deploy-test.yml

🔌 SveleteKit AWS adapter with multiple architecture

Introduction

If you are building a SPA, consider AWS Amplify + adapter-static.
If you want to use always-on servers (not serverless), consider EC2 (ECR) + adapter-node.

Install

  1. Install AWS CLI in local machine

  2. Configure authentication and access credentials in AWS CLI

  3. Install adapter in your SvelteKit project

npm i -D @jill64/sveltekit-adapter-aws
  1. If using pnpm, additional dependency is required.
pnpm i -D aws-cdk-lib dotenv
// svelte.config.js
import adapter from '@jill64/sveltekit-adapter-aws'

const config = {
  // ...
  kit: {
    adapter: adapter({
      name: 'Your Application Name',
      deploy: true,
      architecture: 'lambda-s3'
      // ...
      // Other Adapter Options
      // ...
    })
  }
}

export default config

See Full Adapter Options

Architecture

This adapter allows you to choose from multiple architectures depending on your use case.

Name Response Streaming Assets Scaling Low Round Trip Unlimited SSG Demo Site (Streaming) Demo Site (Bufffered)
lambda-mono ✅ ✅ Link Link
lambda-s3(Default) ✅ ✅ ✅ Link Link
edge-bundled ✅ ✅ ✅ Link
edge-unbundled ✅ ✅ ✅ Link Link

CI/CD Pipeline

GitHub Actions Example

  1. Setup AWS CLI (Not required in GitHub Actions)
  2. Setup AWS Credential
  3. Build Application with deploy: true option

CDK Bootstrap

The first time the AWS CDK stack is deployed, bootstrap must be run. Normally this is handled automatically by the adapter. However, this requires additional permissions, so you can optionally skip the bootstrap step.

{
  // Adapter Option
  skipBootstrap: true
  // ...
}

Manual Deploy

If the automatic deployment option is false, you can deploy the app at any time by running the following command after the app build is complete.

cd ./build && npx cdk deploy

Delete All Resources

cd ./build && npx cdk destroy --all

License

MIT