Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support AWS via SST in adapter-auto #9874

Merged
merged 4 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-ducks-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-auto': patch
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
---

[feat] support AWS via SST
1 change: 1 addition & 0 deletions documentation/docs/25-build-and-deploy/30-adapter-auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ When you create a new SvelteKit project with `npm create svelte@latest`, it inst
- [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/)
- [`@sveltejs/adapter-vercel`](adapter-vercel) for [Vercel](https://vercel.com/)
- [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa) for [Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/)
- [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/master/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte)

It's recommended to install the appropriate adapter to your `devDependencies` once you've settled on a target environment, since this will add the adapter to your lockfile and slightly improve install times on CI.

Expand Down
60 changes: 60 additions & 0 deletions documentation/docs/25-build-and-deploy/95-adapter-aws-sst.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: AWS via SST
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we'd want to add any docs here. We've only added docs for adapters we maintain. We could potentially link to external docs though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For comparison, the adapter-auto docs link out to the svelte-adapter-azure-swa docs rather than including them on kit.svelte.dev — I think that's the right approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense! Removed.

---

To deploy to AWS via SST, use [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/master/packages/svelte-kit-sst).

This adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project allows you to specify SST-specific options.

## Usage

Install with `npm i -D svelte-kit-sst`, then add the adapter to your `svelte.config.js`:

```js
// @errors: 2307 2345
/// file: svelte.config.js
import adapter from 'svelte-kit-sst';

export default {
kit: {
adapter: adapter()
}
};
```

## Quickstart

1. Create a SvelteKit app
1. Run `npx create-sst`
1. It should detect that you are using Svelte and ask you to confirm.
1. Once you're ready for deployment you can run `npx sst deploy --stage=production`

### SST constructs
To use any [additional SST constructs](https://docs.sst.dev/), add them to `sst.config.ts`.

```ts
/// file: sst.config.ts
app.stack(function Site(ctx) {
const bucket = new Bucket(ctx.stack, "public");
const site = new SvelteKitSite(ctx.stack, "site", {
bind: [bucket],
});

ctx.stack.addOutputs({
url: site.url,
});
});
```

And then access them in your `+page(.server).ts` file.

```ts
/// file: +page.server.ts
import { Bucket } from "sst/node/bucket"

console.log(Bucket.public.bucketName)
```

Consult the [SST docs on Resource Binding](https://docs.sst.dev/resource-binding) to learn more

If you have any questions, you can [ask in the SST Discord](https://discord.gg/sst).
6 changes: 6 additions & 0 deletions packages/adapter-auto/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@ export const adapters = [
test: () => process.env.GITHUB_ACTION_REPOSITORY === 'Azure/static-web-apps-deploy',
module: 'svelte-adapter-azure-swa',
version: '0.13'
},
{
name: 'AWS via SST',
test: () => !!process.env.SST,
module: 'svelte-kit-sst',
version: '2'
}
];