-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: Writing Adapters | ||
--- | ||
|
||
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. | ||
|
||
Adapters must implement the following API: | ||
``` | ||
export default function () { | ||
/** @type {import('@sveltejs/kit').Adapter} */ | ||
return { | ||
name: '', | ||
async adapt({ utils, config }) { | ||
} | ||
}; | ||
} | ||
``` | ||
|
||
Within the `adapt` method, there are a few things an adapter should do: | ||
- Clear out the build directory | ||
- Provide code that runs: | ||
- Call `init` | ||
- Convert from the patform's request to a SvelteKit request, call `render`, convert from a SveteKit reponse to the platform's | ||
- Adapters typically bundle the output to avoid needing to install dependencies on the target platform, etc. | ||
- Globally shim `fetch` to work on the target platform. SvelteKit provides a `@sveltejs/kit/install-fetch` helper to use `node-fetch` | ||
- Call `prerender` | ||
- Put the user's static files and the generated JS/CSS in the correct location for the target platform |