npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kontsedal/olas-svelte

v1.0.1

Published

Olas Svelte adapter — setRoot/getRoot context and store views over queries, fields and mutations. Olas signals are Svelte stores as they are.

Readme

@kontsedal/olas-svelte

The Svelte adapter for Olas. An Olas ReadSignal already satisfies Svelte's store contract: its subscribe(run) calls run with the current value at once and on every change, and returns the unsubscribe. So $count works on a signal with no wrapper. This package adds the root context and one store per multi-signal object: a query, an infinite query, a field and a mutation.

Install

pnpm add @kontsedal/olas-svelte @kontsedal/olas-core @preact/signals-core svelte

svelte >= 4 is a peer dependency. The tests run on Svelte 5, and the examples below use Svelte 5 syntax: on Svelte 4, write on:click where they write onclick.

Example

// root.ts: the controller knows nothing about Svelte
import { createRoot, defineController, signal } from '@kontsedal/olas-core'

export const root = createRoot(
  defineController(() => {
    const count = signal(0)
    return { count, inc: () => count.set(count.peek() + 1) }
  }),
  { deps: {} },
)

// Register the root's type once, so `getRoot()` needs no type argument.
declare module '@kontsedal/olas-svelte' {
  interface Register {
    root: typeof root
  }
}
<!-- App.svelte: provide the root to the tree below -->
<script lang="ts">
  import { setRoot } from '@kontsedal/olas-svelte'
  import Counter from './Counter.svelte'
  import { root } from './root'

  setRoot(root)
</script>

<Counter />
<!-- Counter.svelte: a signal is a store -->
<script lang="ts">
  import { getRoot } from '@kontsedal/olas-svelte'

  const api = getRoot()
  const count = api.count
</script>

<button onclick={api.inc}>{$count}</button>

API

| Export | Purpose | |---|---| | setRoot(root) | Provide a root to the component tree below. Call it while a component initializes. | | getRoot<Api>() | The nearest root's api. Register types it; a type argument is an unchecked cast. Throws when no ancestor called setRoot. | | queryStore(subscription) | One store over a query's state: $q.data, $q.isLoading and the rest update together. Carries refetch, reset and cancel. | | infiniteQueryStore(subscription) | The same, plus pages, flat and the paging flags, and fetchNextPage / fetchPreviousPage. | | fieldStore(field) | One store over a field's value and validation state, plus the field's actions. Binds as bind:value={$state.value}. | | mutationStore(mutation) | One store over a mutation's state, plus mutate, run and reset. |

Register and RegisteredApi type getRoot(). Each store's type is exported: QueryStore, InfiniteQueryStore, FieldStore and MutationStore, with the matching …State.

How it behaves

  • A field binds as it is. Field has set, which makes it a writable store, so <input bind:value={$name} /> writes through field.set. Reach for fieldStore when the input also shows errors, and bind its member: <input bind:value={$state.value} />. Svelte writes a member binding by assigning the member on the value it holds and passing that whole value to set. fieldStore hands each subscriber its own copy of the state, and its set writes a copy's value to the field.
  • An object-valued field binds by member. Bind <input bind:value={$person.value.first} /> through fieldStore, or <input bind:value={$person.first} /> on the raw field. Svelte assigns the member in place and passes the object back to set. That counts as a change even when it is the object the field holds, so validators run and isDirty follows, at any depth. The field keeps its baseline as a copy of its own, so reset() restores the value from before the edit. fieldStore hands Svelte a shallow copy, so a top-level member lands on the copy. A deeper member, or any member on a raw field, lands on the object the field holds. When that object is shared, say query data seated through a form's initial, bind a Form's leaf fields instead.
  • Bind a form's leaf fields, not members of $form. A Form and a FieldArray have set too, so bind:value={$form.name} compiles. Svelte then assigns name on the form's current value object in place before it calls form.set. The form ends right, but a value object you held earlier, such as a last-saved snapshot, changes under you. Bind the field: <input bind:value={$name} /> with const name = form.fields.name.
  • One store per object, one update per change. queryStore derives its value from every signal on the query, so a batch of writes reaches the component once.
  • Svelte manages the subscriptions. A $store read subscribes when the component mounts and unsubscribes when it is destroyed.
  • mutate is fire-and-forget. It returns nothing, and a failure lands on $save.error and $save.status. The adapter catches the rejection, so it does not become an unhandled one. run returns the promise, and the caller owns its rejection.

Testing

A controller tests without Svelte, through createTestController from @kontsedal/olas-core/testing. Component tests need the Svelte compiler plugin and the browser resolve condition, or svelte resolves to its server build and mount throws. The root vitest.config.ts runs them as their own project for that reason. packages/integration/tests/adapter-parity/ runs the same scenarios through this adapter, React, preact/compat and Vue, and asserts the same DOM.