Add to existing app

Example of adding Telefunc to an existing app: 7178fec.

  1. npm install telefunc (or pnpm/yarn) (example package.json)
  2. Add Telefunc's Vite plugin (example vite.config.ts)
  3. Add Telefunc's server middleware (example src/routes/_telefunc/+server.ts)
  4. Define your first .telefunc.js file (example src/routes/Counter.telefunc.ts)
  5. Optionally: globally define the type your context object (example src/telefunc.d.ts)

That's it. Enjoy end-to-end typesafety with automatic runtime validation.

Initial page data

We recommend against using Telefunc for fetching the initial data of a page (aka SSR data). Instead, use SvelteKit's built-in data fetching mechanism.

We can still use Telefunc for fetching data after the initial rendering of the page, for example pagination and infinite scroll.