Marketplace

notification-center

Other

togo notification center — in-app inbox, unread counts & live bell

togo-framework
bash
togo install togo-framework/notification-center

Install

bash
togo install togo-framework/notification-center

The togo answer to Laravel's database notifications / an in-app notification bell. It complements notifications (which delivers to external providers like email/Slack/push) by storing a per-user inbox you can list, count, and mark read.

Usage

go
nc, _ := notificationcenter.FromKernel(k)

// Store a notification for a user.
nc.Notify(ctx, "user-1", notificationcenter.Notification{
    Type:      "comment",
    Title:     "New comment",
    Body:      "Sam replied to your post",
    ActionURL: "/posts/9",
    Data:      map[string]any{"post_id": 9},
})

unread := nc.UnreadCount("user-1")               // bell badge
items  := nc.List("user-1", notificationcenter.Filter{UnreadOnly: true})
nc.MarkRead(items[0].ID)
nc.MarkAllRead("user-1")
nc.Delete(items[0].ID)

REST API

The acting user is resolved from the X-User-Id header (or an auth claim on the context).

Method
Path
Description
GET/api/notifications?unread=trueList the inbox (newest first)
GET/api/notifications/unread-count{ "count": N } for the bell
POST/api/notifications/{id}/readMark one read
POST/api/notifications/read-allMark all read
DELETE/api/notifications/{id}Delete one
Rows per page
1–5 of 5
Page 1 of 1

Configuration

No required env. Storage defaults to a bounded in-memory store; swap a DB-backed implementation with nc.WithStore(myStore) (implements the Store interface). If a realtime broker is configured, wire Notify to publish so the bell updates live.


<div align="center"> <h3>Premium sponsors</h3> <p> <a href="https://id8media.com"><strong>ID8 Media</strong></a> &nbsp;·&nbsp; <a href="https://one-studio.co"><strong>One Studio</strong></a> </p> <p><sub>Support togo — <a href="https://github.com/sponsors/fadymondy">become a sponsor</a>.</sub></p> </div>