Install the Notifications Widget as an NPM package for first-class React (and TypeScript) support. Supports authenticated access via postMessage, auto-refresh, and full CSS variable theming.
npm install @legionhandtech/lht-react-widgetsReact 17+ is a peer dependency. If your project already has React installed you're good to go.
1import { LegionNotifications } from '@legionhandtech/lht-react-widgets';
2
3function App() {
4 return (
5 <LegionNotifications
6 baseUrl="https://your-legion-domain.com"
7 authToken="your-jwt-token"
8 userId="user-42"
9 theme="light"
10 maxNotifications={10}
11 />
12 );
13}You can also import from the dedicated sub-path:
import { LegionNotifications } from '@legionhandtech/lht-react-widgets/notifications';| Prop | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | Base URL of your Legion deployment |
authToken | string | — | JWT / API key for authenticated access (sent via postMessage, never in URL) |
userId | string | — | User ID for notification lookup |
theme | "light" | "dark" | "light" | Theme preset |
maxNotifications | number | 10 | Maximum number of notifications to display |
autoRefresh | boolean | true | Enable auto-refresh (every 30 seconds) |
emptyTitle | string | "You're all caught up" | Title shown in empty state |
emptySubtitle | string | "No notifications right now" | Subtitle shown in empty state |
accentColor | string | "blue" (light) / "gray" (dark) | Accent color name |
emptyIcon | "bell" | "gift" | "activity" | "trophy" | "bell" | Icon for empty state |
width | string | "100%" | Widget width (CSS value) |
height | string | "400px" | Widget height (CSS value) |
className | string | — | CSS class applied to the outer container |
style | React.CSSProperties | — | Inline styles merged into the container |
onLoad | (detail) => void | — | Called when the widget iframe finishes loading |
onError | (message: string) => void | — | Called if the widget iframe fails to load |
All 45 theming props are optional. Here are the most commonly used ones:
| Prop | CSS Variable | Example |
|---|---|---|
notifPrimaryColor | --notif-primary-color | "#228be6" |
notifBackgroundColor | --notif-background-color | "#f8f9fa" |
notifTextColor | --notif-text-color | "#333" |
notifItemBg | --notif-item-bg | "#fff" |
notifItemRadius | --notif-item-radius | "12px" |
notifUnreadBg | --notif-unread-bg | "#e7f5ff" |
notifBadgeBg | --notif-badge-bg | "#ff6b6b" |
notifBadgeColor | --notif-badge-color | "#fff" |
notifFontFamily | --notif-font-family | "Inter, sans-serif" |
notifBorderRadius | --notif-border-radius | "12px" |
notifButtonBg | --notif-button-bg | "#228be6" |
notifButtonRadius | --notif-button-radius | "6px" |
See the TypeScript NotificationsThemingProps interface for the complete list.
1import { useRef } from 'react';
2import { LegionNotifications, LegionNotificationsHandle } from '@legionhandtech/lht-react-widgets';
3
4function App() {
5 const widgetRef = useRef<LegionNotificationsHandle>(null);
6
7 return (
8 <>
9 <button onClick={() => widgetRef.current?.refresh()}>
10 Refresh Notifications
11 </button>
12 <LegionNotifications
13 ref={widgetRef}
14 baseUrl="https://your-legion-domain.com"
15 authToken="your-jwt-token"
16 />
17 </>
18 );
19}| Method | Description |
|---|---|
refresh() | Reloads the widget iframe |
import '@legionhandtech/lht-react-widgets/notifications-web-component';1<legion-notifications
2 base-url="https://your-legion-domain.com"
3 api-key="your-api-key"
4 user-id="user-42"
5 theme="light"
6 max-notifications="10"
7 auto-refresh="true"
8 accent-color="blue">
9</legion-notifications>1import type {
2 NotificationsWidgetProps,
3 NotificationsThemingProps,
4 LegionNotificationsHandle,
5} from '@legionhandtech/lht-react-widgets';1<LegionNotifications
2 baseUrl="https://your-legion-domain.com"
3 authToken="your-jwt-token"
4 onLoad={(detail) => {
5 console.log(detail.widget); // "notifications"
6 console.log(detail.theme); // "light" | "dark"
7 }}
8/>1<LegionNotifications
2 baseUrl="https://your-legion-domain.com"
3 onError={(message) => console.error(message)}
4/>