lib/notifications.ts

9router-go · web/src/lib/notifications.ts · typescript · MIT
ui, UI / Frontend

Svelte store implementing a global toast notification system.

// Source: https://github.com/luqman-v1/9router-go | License: MIT | Copyright 2024-2026 decolua and contributors
// Provided via justclaw.it.com; keep this notice with the code.
// Port of upstream src/store/notificationStore.js (zustand) to a Svelte store.
// Global toast notification system used across dashboard pages.
import { writable } from 'svelte/store'

export type NotificationType = 'success' | 'error' | 'warning' | 'info'

export interface Notification {
  id: number
  type: NotificationType
  message: string
  title?: string | null
  duration: number
  dismissible: boolean
}

let idCounter = 0

function createNotificationStore() {
  const { subscribe, update } = writable<Notification[]>([])

  function removeNotification(id: number) {
    update((list) => list.filter((n) => n.id

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key