Skip to content

v4.1.0

Latest

Choose a tag to compare

@icflorescu icflorescu released this 14 Nov 14:10
420fc6d

tRPC-SvelteKit v4.1 brings first-class support for TanStack Svelte Query, fixes for the experimental WebSocket support, and LLM-friendly docs.

npm i trpc-sveltekit@4.1

No breaking changes: upgrading from v4.0 is a matter of updating the package.

Highlights

  • TanStack Svelte Query: the new createTRPCQueryOptions turns your tRPC client into typed query and mutation options and query keys, so you don't have to write query keys or query functions yourself. It covers queryOptions, mutationOptions, queryKey, mutationKey and pathKey, using the key format of tRPC's own TanStack Query integration, and depends on no TanStack Query package. See the Svelte Query guide and the new Svelte Query page in the simple example.
    const api = createTRPCQueryOptions(trpc(page));
    const authors = createQuery(() => api.authors.list.queryOptions('smith'));
  • WebSocket shutdown: SvelteKitTRPCWSServer no longer keeps the process running after SIGTERM/SIGINT while clients are connected. It now closes the connections (with code 1001, so clients reconnect) and lets adapter-node shut down gracefully. The new closeWSSGlobalInstance() does the same for custom servers.
  • WebSocket connections: connections made before a router is attached (e.g. in development, before SvelteKit loads your hooks) are now refused, so clients retry instead of hanging. The docs also cover WebSocket authentication now.
  • Bun: @sveltejs/adapter-bun is verified to work, including streaming and subscriptions over server-sent events.
  • LLM-friendly docs: llms.txt and llms-full.txt for AI assistants and coding agents (how to use them).
  • Changelog: notable changes are now recorded in CHANGELOG.md.

See the changelog for the full list, including the docs website fixes.