You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/docs/10-adapters.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,14 +33,13 @@ export default {
33
33
34
34
A variety of official adapters exist for serverless platforms...
35
35
36
-
-[`adapter-begin`](https://github.com/sveltejs/kit/tree/master/packages/adapter-begin) — for [Begin](https://begin.com)
37
36
-[`adapter-cloudflare-workers`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare-workers) — for [Cloudflare Workers](https://developers.cloudflare.com/workers/)
38
37
-[`adapter-netlify`](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify) — for [Netlify](https://netlify.com)
39
38
-[`adapter-vercel`](https://github.com/sveltejs/kit/tree/master/packages/adapter-vercel) — for [Vercel](https://vercel.com)
40
39
41
-
...and others:
40
+
...and traditional platforms:
42
41
43
42
-[`adapter-node`](https://github.com/sveltejs/kit/tree/master/packages/adapter-node) — for creating self-contained Node apps
44
43
-[`adapter-static`](https://github.com/sveltejs/kit/tree/master/packages/adapter-static) — for prerendering your entire site as a collection of static files
45
44
46
-
> The adapter API is still in flux and will likely change before 1.0.
45
+
As well as [community-provided adapters](https://github.com/sveltejs/integrations#sveltekit-adapters). You may also [write your own adapter](#writing-an-adapter).
We recommend [looking at the source for an adapter](https://github.com/sveltejs/kit/tree/master/packages) to a platform similar to yours and copying it as a starting point.
6
+
7
+
Adapters packages must implement the following API, which creates an `Adapter`:
8
+
```
9
+
/**
10
+
* @param {AdapterSpecificOptions} options
11
+
*/
12
+
export default function (options) {
13
+
/** @type {import('@sveltejs/kit').Adapter} */
14
+
return {
15
+
name: '',
16
+
async adapt({ utils, config }) {
17
+
}
18
+
};
19
+
}
20
+
```
21
+
22
+
The types for `Adapter` and its parameters are available in [types/config.d.ts](https://github.com/sveltejs/kit/blob/master/packages/kit/types/config.d.ts).
23
+
24
+
Within the `adapt` method, there are a number of things that an adapter should do:
25
+
- Clear out the build directory
26
+
- Output code that:
27
+
- Calls `init`
28
+
- Converts from the patform's request to a [SvelteKit request](#hooks-handle), calls `render`, and converts from a [SvelteKit response](#hooks-handle) to the platform's
29
+
- Globally shims `fetch` to work on the target platform. SvelteKit provides a `@sveltejs/kit/install-fetch` helper for platforms that can use `node-fetch`
30
+
- Bundle the output to avoid needing to install dependencies on the target platform, if desired
31
+
- Call `utils.prerender`
32
+
- Put the user's static files and the generated JS/CSS in the correct location for the target platform
0 commit comments