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

@uraiai/chat-widget-svelte

v0.1.4

Published

Svelte 5 component for the Urai chat widget

Readme

@uraiai/chat-widget-svelte

Svelte 5 component for the Urai chat widget.

npm install @uraiai/chat-widget-svelte
<script lang="ts">
  import { UraiChatWidget } from "@uraiai/chat-widget-svelte";

  let widget: UraiChatWidget;
</script>

<button onclick={() => widget.getController()?.open()}>Chat with us</button>

<UraiChatWidget
  bind:this={widget}
  widgetToken="<widget token>"
  userId="<stable visitor id>"
  theme={{ primaryColor: "#0ea5e9" }}
  onassistantreply={(content) => console.log(content)}
/>

Allow your origin. The server validates the Origin header of every widget request (including the SSE stream) against the widget's allowed origins. Add your app's origin in the Urai dashboard or all requests 403.

Props

Required: widgetToken, userId. Optional: baseUrl (defaults to https://chat.app.urai.dev; set it for self-hosted deployments), vars, theme, layout, behavior, mode ("floating" default | "inline"), and callback props onready, onopened, onclosed, onusermessage, onassistantreply, oncommand, onerror.

oncommand fires when a uraiJS tool calls meta.urai.sendCommand(meta.vars.thread_id, payload) during the turn — use it to react to tool-driven UI signals (e.g. navigation). The payload is the tool author's JSON, verbatim: treat it as untrusted and validate its shape before acting. Delivered only while the turn's stream is open; each open widget instance receives its own copy.

In inline mode the component renders a div and the chat panel fills it — size it via the parent element.

Prop changes: live vs. remount

| Prop | Effect | |---|---| | theme, layout, behavior | Applied live via configure() (deep-compared). Structural changes (mode/position/header/welcome/suggested) rebuild the panel and clear the visible conversation. | | userId | setUser() — resets the conversation for the new visitor. | | vars | setVars() — updates the current/next thread's context. | | widgetToken, baseUrl, mode | Destroys and recreates the widget. |

bind:this gives you the component instance; call getController() on it for the full WidgetController (open, close, sendMessage, startConversation, on, …). It returns null until mounted.

Passing context (vars)

Vars are a JSON object stored on the thread and made available to your assistant (plan, locale, current route, …). The idiomatic way is the vars prop — changing it calls setVars() on the active thread (deep-compared, so inline literals are fine):

<script lang="ts">
  import { page } from "$app/state";
  import { UraiChatWidget } from "@uraiai/chat-widget-svelte";
</script>

<UraiChatWidget
  widgetToken="<widget token>"
  userId="user_42"
  vars={{ plan: "pro", page: page.url.pathname }}
/>

Or imperatively through the controller:

widget.getController()?.setVars({ plan: "pro" });          // update active thread
widget.getController()?.setVars(null);                     // clear
widget.getController()?.startConversation({ topic: "billing" }); // seed a fresh thread