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

@lyeve-labs/client-svelte

v0.1.8

Published

Svelte 5 reactive stores for the LyEve Core API - thin wrapper around @lyeve-labs/client using $state runes

Readme

@lyeve-labs/client-svelte

Svelte 5 reactive stores for the LyEve CMS API. Thin wrapper around @lyeve-labs/client using Svelte 5 runes ($state).

License: MIT Svelte 5 TypeScript

pnpm add @lyeve-labs/client @lyeve-labs/client-svelte
<script lang="ts">
  import { createCmsClient, createAsyncStore } from '@lyeve-labs/client-svelte';
  import { getSchemas } from '@lyeve-labs/client-rest';

  const client = createCmsClient({
    baseUrl: 'https://cms.example.com',
    getHeaders: () => ({ Authorization: `Bearer ${token}` }),
  });

  const schemas = createAsyncStore((client) => getSchemas(client), client);
</script>

{#if schemas.loading}
  <p>Loading...</p>
{:else if schemas.error}
  <p>Error: {schemas.error.message}</p>
{:else}
  <ul>
    {#each schemas.data ?? [] as schema}
      <li>{schema.name}</li>
    {/each}
  </ul>
{/if}

No Provider needed. Create a client, pass it in, done.


What's in the box

  • createCmsClient: factory that returns a configured HttpClient with base URL and dynamic headers.
  • createAsyncStore: reactive async data store built on $state. Returns { data, error, loading, refetch }. All reactive, no boilerplate.
  • createAuthStore: auth state store with reactive user, token, and isAuthenticated. Methods to setUser, clear, and load from storage.
  • Svelte 5 native: built on runes. No legacy stores, no writable.

Requirements

Install

pnpm add @lyeve-labs/client @lyeve-labs/client-svelte
# or npm install @lyeve-labs/client @lyeve-labs/client-svelte
# or yarn add @lyeve-labs/client @lyeve-labs/client-svelte

The examples below fetch through the REST helpers, which ship separately. Add @lyeve-labs/client-rest if you want them, or pass any fetcher of your own.

Use

Data fetching

<script lang="ts">
  import { createCmsClient, createAsyncStore } from '@lyeve-labs/client-svelte';
  import { getSchemas } from '@lyeve-labs/client-rest';

  const client = createCmsClient({
    baseUrl: 'https://cms.example.com',
    getHeaders: () => ({ Authorization: `Bearer ${token}` }),
  });

  const schemas = createAsyncStore((c) => getSchemas(c), client);
</script>

{#if schemas.loading}
  <p>Loading...</p>
{:else if schemas.error}
  <p>Error: {schemas.error.message}</p>
{:else}
  <ul>
    {#each schemas.data ?? [] as schema}
      <li>{schema.name}</li>
    {/each}
  </ul>
{/if}

<button onclick={() => schemas.refetch()}>Reload</button>

Authentication

<script lang="ts">
  import { createCmsClient, createAuthStore } from '@lyeve-labs/client-svelte';

  const client = createCmsClient({ baseUrl: 'https://cms.example.com' });
  const auth = createAuthStore(client);

  function handleLogin(e: SubmitEvent) {
    e.preventDefault();
    const data = new FormData(e.target as HTMLFormElement);
    const credentials = {
      email: data.get('email') as string,
      password: data.get('password') as string,
    };
    // Call your auth endpoint, then store the result:
    const user = { id: '1', email: credentials.email, roles: ['admin'] };
    auth.setUser(user, 'jwt-token');
  }
</script>

{#if !auth.isAuthenticated}
  <form onsubmit={handleLogin}>
    <input type="email" name="email" required />
    <input type="password" name="password" required />
    <button type="submit">Log in</button>
  </form>
{:else}
  <p>Welcome, {auth.user?.email}</p>
  <button onclick={() => auth.clear()}>Log out</button>
{/if}

API

createCmsClient(config)

function createCmsClient(config: {
  baseUrl?: string;
  getHeaders?: () => Record<string, string>;
}): HttpClient;

createAsyncStore(fetcher, client)

function createAsyncStore<T>(
  fetcher: (client: HttpClient) => Promise<T>,
  client: HttpClient,
): {
  data: T | null;
  error: Error | null;
  loading: boolean;
  refetch: () => void;
};

All fields are reactive ($state rune).

createAuthStore(client)

function createAuthStore(client: HttpClient): {
  user: { id: string; email: string; roles: string[] } | null;
  token: string | null;
  isAuthenticated: boolean;
  setUser: (user: User, token: string) => void;
  clear: () => void;
  load: () => Promise<void>;
};

Local development

pnpm install            # install dependencies
pnpm test               # run unit tests
pnpm check              # type-check
pnpm build              # tsup + publint -> dist/

Project layout

src/
  index.ts           # public API (re-exports)
  index.svelte.ts    # Svelte 5 entry point
  runes.ts           # createAsyncStore, createAuthStore
  ambient.d.ts       # type declarations
tests/               # vitest test suite

Versioning

@lyeve-labs/client-svelte follows SemVer. While under 1.0, breaking changes bump the minor version; additive changes bump the patch. Every release is logged in CHANGELOG.md.

Contributing

Bug reports and feature requests are welcome. See CONTRIBUTING.md for the development setup and conventions.

License

MIT. See LICENSE.