Islands for SvelteKit
The sveltekit-islands plugin is a Vite plugin and Svelte preprocessor designed to seamlessly integrate the Islands architecture into SvelteKit applications. Islands is a rendering pattern that encourages small, focused chunks of interactivity within server-rendered web pages. This plugin allows for the creation of islands, which are small elements of interactivity, within otherwise static HTML pages.
To install the sveltekit-islands plugin, follow these steps:
// Global layout
// Enable prerender
prerender: true
// Disable csr
csr: false
// Vite config
import { islandsVitePlugin } from 'sveltekit-islands'
plugins: [
islandsVitePlugin()
]
// Svelte config
import { islandsSveltePreprocessor } from 'sveltekit-islands'
preprocess: [
islandsSveltePreprocessor()
]
Note: Currently, only the static adapter is officially supported and known to be working. If your adapter of choice doesn’t work, you can open an issue.
// Svelte component
<script>
import { Island } from 'sveltekit-islands'
</script>
<Island>
<!-- Island content -->
</Island>
For more information on the props you can pass to the Island component, refer to the plugin’s documentation.
The sveltekit-islands plugin is a powerful tool for seamlessly integrating the Islands architecture into SvelteKit applications. It enables the creation of islands, small elements of interactivity, within static HTML pages. With features like progressive enhancement and multiple entry points, this plugin is particularly useful for content-heavy websites that require little interactivity sprinkled in, such as landing pages and blogs. It offers a better experience by allowing the use of Svelte components for interactivity instead of plain old vanilla JavaScript. This plugin is heavily inspired by @11ty/is-land and Geoff Rich’s blog post on the topic, taking the idea of islands to a new level of seamless integration.