Skip to content

Installation

As the name suggests @sheepdog/svelte is meant to be used in a svelte project.

To install, run the following command with your preferred package manager.

Terminal window
npm install @sheepdog/svelte

Setup the Async Transform

The Async Transform is a Vite plugin so to set it up you need to modify your vite.config.{js|ts}

vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { asyncTransform } from '@sheepdog/svelte/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig(({ mode }) => ({
plugins: [
sveltekit(),
asyncTransform(),
],
// rest of your config
}));

And that’s it! You can now use async tasks with proper mid-run cancellation!

Remember: the Async Transform will only change your code in some very specific places, read more about it in the async transform explainer.