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

@qredex/svelte

v1.1.4

Published

Svelte wrapper for Qredex Agent

Readme

@qredex/svelte

Thin Svelte bindings for @qredex/agent.

CI Release npm version license

Install

npm install @qredex/svelte

Attribution Flow

Svelte wrapper attribution flow

Call useQredexAgent(), then forward merchant cart state with agent.handleCartChange(...), read the PIT with agent.getPurchaseIntentToken(), and clear attribution with agent.handleCartEmpty(). Only call agent.handlePaymentSuccess() if your platform has no cart-empty step after checkout.

Merchant Integration Checklist

  • Initialize the wrapper in the cart surface you already own
  • Report every real merchant cart transition with agent.handleCartChange(...)
  • Read PIT during checkout or order assembly
  • Send order + PIT to your backend or direct ingestion path
  • Clear attribution with agent.handleCartEmpty() or agent.handlePaymentSuccess()

Recommended Integration

Use useQredexAgent() inside the existing cart surface you already own. The wrapper stays headless. The merchant still owns cart APIs, totals, checkout, and order submission. Qredex only needs the cart transition so the core runtime can lock IIT to PIT. After lock, the merchant reads that PIT and carries it with the normal order payload to the merchant backend or direct Qredex ingestion path.

<script lang="ts">
  import { useQredexAgent } from '@qredex/svelte';

  export let itemCount = 0;

  const { agent, state } = useQredexAgent();
  let previousCount = itemCount;

  $: if (itemCount !== previousCount) {
    // [Qredex] Report the cart transition after your merchant cart changes.
    agent.handleCartChange({
      itemCount,
      previousCount,
    });

    // [Merchant] Keep your local snapshot ready for the next transition.
    previousCount = itemCount;
  }

  async function clearCart() {
    // [Merchant] Clear the real cart in your own backend/storefront first.
    await fetch('/api/cart/clear', {
      method: 'POST',
    });

    // [Qredex] Clear attribution because the merchant cart is now empty.
    agent.handleCartEmpty();
  }

  async function submitOrder() {
    // [Qredex] Read PIT from wrapper state, with the core runtime as fallback.
    const pit = $state.pit ?? agent.getPurchaseIntentToken();

    // [Merchant] Send the PIT as part of your normal order payload so the
    // backend can carry order + PIT into attribution ingestion.
    await fetch('/api/orders', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        orderId: 'order-123',
        qredex_pit: pit,
      }),
    });

    // [Merchant + Qredex] Reuse the same clear path after checkout succeeds.
    await clearCart();
  }
</script>

<div>
  <span>Qredex status: {$state.locked ? 'locked' : 'waiting'}</span>
  <button on:click={clearCart}>Clear cart</button>
  <button disabled={!$state.hasPIT} on:click={submitOrder}>
    Send PIT to backend
  </button>
</div>

What To Call When

| Merchant event | Call | Why | |---|---|---| | Cart becomes non-empty | agent.handleCartChange({ itemCount, previousCount }) | Gives Qredex the live cart state so IIT can lock to PIT | | Cart changes while still non-empty | agent.handleCartChange(...) | Safe retry path on the next merchant-reported non-empty cart event if a previous lock failed | | Clear cart action | clearCart() -> agent.handleCartEmpty() | Clears IIT/PIT from the live session | | Need PIT for order submission | $state.pit or agent.getPurchaseIntentToken() | Attach PIT to the checkout payload | | Checkout completes without a cart-empty step | agent.handlePaymentSuccess() | Optional explicit cleanup path |

API Surface

| Export | Use | |---|---| | useQredexAgent() | Primary Svelte composable. Returns { agent, state } | | useQredex() | Deprecated alias for useQredexAgent() | | createQredexStateStore() | State store only, without the convenience composable | | getQredexAgent() | Direct access to the singleton runtime | | initQredex() | Explicit browser init when needed | | QredexAgent | Re-export of the core agent |