Svelte Kit

Vite

Build with Vite with 2 plugins

SSR

ssr.externals

Typings

Generated types

https://github.com/sveltejs/kit/discussions/4571 (opens in a new tab)

For each src/routes/[foo]/[bar]/[baz].js, there is generated type file under e.g. .svelte-kit/types/src/routes/[foo]/[bar]/[baz].d.ts.

It works as

/** @type {import('./[baz]').RequestHandler} */
export async function get({ params }) {
  // ...
}

app-level types

https://github.com/sveltejs/kit/issues/3569 (opens in a new tab)

// global.d.ts
 
declare module '$app/stores' {
  export interface Session {
     whatever: 'i want';
   }
}

Endpoint

Page vs Standalone

Load function vs Get/Post for loading page data (issue https://github.com/sveltejs/kit/issues/3532 (opens in a new tab))

Module script (<script context='module' />)

https://codechips.me/svelte-module-scripts-explained/ (opens in a new tab)

Conceptually similar to ES Modules, while script is similar to props/data/methods/hooks in vue.