Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
import { createContext, useContext } from "react";
export interface Notification {
message: string;
type: "error" | "success" | "info";
duration?: number; // in milliseconds
}
export interface NotificationContextType {
notifications: Notification[];
addNotification: (notification: Notification) => void;
removeNotification: (id: string) => void;
removeAllNotifications: () => void;
}
export const NotificationContext = createContext<
NotificationContextType | undefined
>(undefined);
export const useNotifications = () => {
const context = useContext(NotificationContext);
if (!context) {
throw new Error(
"useNotifications must be used within a NotificationProvider"
);
}
return context;
};