Skip to content

JS+ 🧡 SvelteKit

  1. Install the necessary dependencies

    Terminal window
    pnpm i -D @jsplang/jsp @jsplang/vite-plugin-jsp
  2. Add the JS+ plugin to your vite.config.js

    import jsp from '@jsplang/vite-plugin-jsp';
    import { defineConfig } from 'vite';
    // https://vite.dev/config/
    export default defineConfig({
    plugins: [jsp()],
    });
  3. Add the JS+ preprocessor to your svelte.config.js

    import jsp from '@jsplang/svelte-preprocess-jsp';
    import adapter from '@sveltejs/adapter-auto';
    /** @type {import('@sveltejs/kit').Config} */
    const config = {
    kit: {
    // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
    // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
    // See https://svelte.dev/docs/kit/adapters for more information about adapters.
    adapter: adapter(),
    },
    preprocess: [jsp()],
    };
    export default config;
  4. Run the development server

    Terminal window
    pnpm dev
  5. Done!