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

watchup-svelte

v0.1.2

Published

SvelteKit SDK for Watchup error tracking

Readme

watchup-svelte

SvelteKit SDK for Watchup – capture client-side errors, stack traces, and Svelte component traces, and report them to your Watchup project.

Think of it like a lightweight, Svelte-native error reporter (similar to Sentry), but built specifically for watchup.site.


✨ Features

  • ✅ Automatic JavaScript error capture
  • ✅ Unhandled promise rejection tracking
  • ✅ Svelte component stack traces
  • ✅ Manual error reporting
  • ✅ Works with SvelteKit (SSR-safe)
  • ✅ Minimal, tree-shakeable ESM package
  • ✅ Configurable API endpoint

📦 Installation

npm install watchup-svelte

or

pnpm add watchup-svelte

🚀 Quick Start

Initialize Watchup once on the client (usually in +layout.svelte).

<script lang="ts">
  import { initWatchup } from 'watchup-svelte'

  initWatchup({
    projectId: 'your_project_id',
    apiKey: 'your_api_key'
  })
</script>

That’s it. Errors are now automatically reported.


🔐 Authentication

Watchup authenticates requests using HTTP headers:

  • X-Watchup-Project → your project ID
  • X-Watchup-Key → your API key

The SDK handles this automatically.


🌍 API Endpoint

By default, events are sent to:

https://watchup-server.vercel.app

You can override this (self-hosting, staging, etc.):

initWatchup({
  projectId: 'your_project_id',
  apiKey: 'your_api_key',
  apiUrl: 'https://your-custom-server.com' (OPTIONAL)
})

🧠 What Gets Captured

Each event includes:

  • Error message
  • Stack trace
  • Svelte component stack (when available)
  • Page URL
  • User agent
  • Timestamp (ISO-8601)

This matches Watchup’s /v1/capture API exactly.


✋ Manual Error Capture

You can manually report errors anywhere in your app:

import { captureException } from 'watchup-svelte'

try {
  riskyOperation()
} catch (err) {
  captureException(err)
}

Useful for:

  • Caught exceptions
  • Custom validation errors
  • Non-fatal issues

🧩 Capturing Svelte Component Errors

To capture Svelte component errors with component stack traces, use the provided helper.

<script lang="ts">
  import { watchupErrorHandler } from 'watchup-svelte'

  export let error
  export let componentStack

  if (error) {
    watchupErrorHandler(error, componentStack)
  }
</script>

This maps directly to Watchup’s componentStack field.


⚙️ SvelteKit Error Hooks (Optional)

You can also capture errors thrown from load() or routing logic.

// hooks.client.ts
import { captureException } from 'watchup-svelte'

export function handleError({ error }) {
  captureException(error)
}

🛡️ SSR Safety

  • No browser APIs are accessed during SSR
  • Error listeners are registered only in the browser
  • Safe to import in SvelteKit layouts

🚦 Rate Limiting

Watchup enforces rate limits per project.

  • Events are sent in a fire-and-forget manner
  • Failed requests are silently ignored
  • Errors inside the SDK never crash your app

📚 API Reference

initWatchup(options)

Initializes the Watchup SDK.

initWatchup({
  projectId: string
  apiKey: string
  apiUrl?: string
})

| Option | Required | Description | | ----------- | -------- | ------------------------- | | projectId | ✅ | Watchup project ID | | apiKey | ✅ | Watchup API key | | apiUrl | ❌ | Custom Watchup server URL |


captureException(error, componentStack?)

Manually report an error.

captureException(error)
captureException(error, 'Component.svelte > Child.svelte')

watchupErrorHandler(error, componentStack)

Helper for Svelte component error boundaries.


🧪 Development Tips

  • Initialize only once (usually in root layout)
  • Avoid calling initWatchup during SSR
  • Do not wrap captureException in try/catch

🗺️ Roadmap

  • Source map support
  • Error deduplication
  • Offline queue & retry
  • User/session tagging
  • Framework SDKs (React, Vue)

📄 License

MIT