{"_id":"@allem-sdk/notifications","name":"@allem-sdk/notifications","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@allem-sdk/notifications","version":"0.1.1","description":"Headless notification/toast system for React. useNotify, useNotifications, NotificationProvider. No UI opinions — bring your own components.","license":"MIT","author":{"name":"Ahmed Allem"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"sideEffects":false,"devDependencies":{"@testing-library/react":"^16.0.0","@types/react":"^19.0.0","jsdom":"^25.0.0","react":"^19.0.0","react-dom":"^19.0.0","tsup":"^8.4.0","typescript":"^5.8.0","vitest":"^3.0.0"},"peerDependencies":{"react":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/kingofmit/allem-sdk.git","directory":"packages/notifications"},"keywords":["allem-sdk","react","react-hooks","notifications","toast","snackbar","alerts","headless","typescript","nextjs"],"publishConfig":{"access":"public"},"scripts":{"build":"tsup","dev":"tsup --watch","clean":"rm -rf dist","test":"vitest run"},"_id":"@allem-sdk/notifications@0.1.1","bugs":{"url":"https://github.com/kingofmit/allem-sdk/issues"},"homepage":"https://github.com/kingofmit/allem-sdk#readme","_integrity":"sha512-h3kTbJu9SKeyy1Kkx3nRRdV+lB/2P+Ymd6RHdLfuEtv10xkfNumbSPAymqTwjaWXiaV1kYKh6naEnVI2rQQZJA==","_resolved":"/private/var/folders/4v/rph2hgm54rqf12vzbjxpn5kc0000gn/T/e7df622b7e3003f7e0e424cca4a88d0a/allem-sdk-notifications-0.1.1.tgz","_from":"file:allem-sdk-notifications-0.1.1.tgz","_nodeVersion":"26.0.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-h3kTbJu9SKeyy1Kkx3nRRdV+lB/2P+Ymd6RHdLfuEtv10xkfNumbSPAymqTwjaWXiaV1kYKh6naEnVI2rQQZJA==","shasum":"9662394826ae3ad41fcd195b085c5f4c55b61056","tarball":"https://registry.npmjs.org/@allem-sdk/notifications/-/notifications-0.1.1.tgz","fileCount":8,"unpackedSize":18086,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD6rYxSiRqchlJPIaeqIQDky1DUWpEs1YxxeRYGHsCTOQIgKQjsizWJMWCHWhshmrWurZ333KtVM4pgtRASCCJZh+k="}]},"_npmUser":{"name":"kingofmit","email":"allem.ahmed@gmail.com"},"directories":{},"maintainers":[{"name":"kingofmit","email":"allem.ahmed@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/notifications_0.1.1_1779571359702_0.24183215286079962"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-23T21:22:39.586Z","0.1.1":"2026-05-23T21:22:39.863Z","modified":"2026-05-23T21:22:40.112Z"},"maintainers":[{"name":"kingofmit","email":"allem.ahmed@gmail.com"}],"description":"Headless notification/toast system for React. useNotify, useNotifications, NotificationProvider. No UI opinions — bring your own components.","homepage":"https://github.com/kingofmit/allem-sdk#readme","keywords":["allem-sdk","react","react-hooks","notifications","toast","snackbar","alerts","headless","typescript","nextjs"],"repository":{"type":"git","url":"git+https://github.com/kingofmit/allem-sdk.git","directory":"packages/notifications"},"author":{"name":"Ahmed Allem"},"bugs":{"url":"https://github.com/kingofmit/allem-sdk/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/kingofmit/allem-sdk/main/.github/AllemSDK.png\" alt=\"Allem SDK\" />\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@allem-sdk/notifications\"><img src=\"https://img.shields.io/npm/v/@allem-sdk/notifications.svg\" alt=\"npm version\" /></a>\n  <a href=\"https://github.com/kingofmit/allem-sdk/blob/main/LICENSE\"><img src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License\" /></a>\n  <img src=\"https://img.shields.io/badge/react-19-61dafb\" alt=\"React 19\" />\n  <img src=\"https://img.shields.io/badge/typescript-strict-blue\" alt=\"TypeScript\" />\n</p>\n\n# @allem-sdk/notifications\n\nHeadless toast and notification system for React. No UI opinions — you control the rendering. Supports auto-dismiss, max count, and notification types.\n\n## Installation\n\n```bash\nnpm install @allem-sdk/notifications\n```\n\n## Usage\n\n```tsx\nimport { NotificationProvider, useNotify, useNotifications } from \"@allem-sdk/notifications\";\n\nfunction App() {\n  return (\n    <NotificationProvider maxCount={5}>\n      <MyApp />\n      <ToastContainer />\n    </NotificationProvider>\n  );\n}\n\nfunction ActionButton() {\n  const { notify } = useNotify();\n\n  return (\n    <button onClick={() => notify({ title: \"Saved!\", type: \"success\" })}>\n      Save\n    </button>\n  );\n}\n\nfunction ToastContainer() {\n  const notifications = useNotifications();\n\n  return (\n    <div style={{ position: \"fixed\", top: 16, right: 16 }}>\n      {notifications.map((n) => (\n        <div key={n.id} style={{ padding: 12, marginBottom: 8, background: \"#333\", color: \"#fff\", borderRadius: 8 }}>\n          <strong>{n.title}</strong>\n          {n.message && <p>{n.message}</p>}\n        </div>\n      ))}\n    </div>\n  );\n}\n```\n\n## NotificationProvider\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `maxCount` | `number` | `5` | Maximum notifications visible at once. Oldest are evicted when exceeded. |\n\n## useNotify\n\nReturns actions for creating and dismissing notifications.\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `notify` | `(options: NotifyOptions) => string` | Create a notification, returns its ID |\n| `dismiss` | `(id: string) => void` | Dismiss a specific notification |\n| `dismissAll` | `() => void` | Dismiss all notifications |\n\n### NotifyOptions\n\n| Property | Type | Default | Description |\n|----------|------|---------|-------------|\n| `title` | `string` | — | Notification title (required) |\n| `type` | `\"info\" \\| \"success\" \\| \"warning\" \\| \"error\"` | `\"info\"` | Notification type |\n| `message` | `string` | — | Optional description text |\n| `duration` | `number` | `5000` | Auto-dismiss in ms. Set to `0` to persist. |\n\n```tsx\nconst { notify, dismiss } = useNotify();\n\n// Basic\nnotify({ title: \"Changes saved\" });\n\n// With type and message\nnotify({ type: \"error\", title: \"Upload failed\", message: \"File too large\" });\n\n// Persistent (no auto-dismiss)\nconst id = notify({ title: \"Uploading...\", type: \"info\", duration: 0 });\n// Later: dismiss(id);\n```\n\n## useNotifications\n\nReturns the current `Notification[]` array for rendering.\n\n```tsx\nconst notifications = useNotifications();\n```\n\n### Notification object\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `id` | `string` | Unique identifier |\n| `type` | `\"info\" \\| \"success\" \\| \"warning\" \\| \"error\"` | Notification type |\n| `title` | `string` | Title text |\n| `message` | `string \\| undefined` | Optional description |\n| `duration` | `number` | Auto-dismiss duration in ms |\n| `createdAt` | `number` | Timestamp (ms since epoch) |\n\n## Exports\n\n| Export | Type | Description |\n|--------|------|-------------|\n| `NotificationProvider` | Component | Context provider with `maxCount` config |\n| `useNotify` | Hook | Returns `{ notify, dismiss, dismissAll }` |\n| `useNotifications` | Hook | Returns current `Notification[]` array |\n\n## Part of [Allem SDK](https://github.com/kingofmit/allem-sdk)\n\nThis package can be used standalone or as part of the full SDK. Install `allem-sdk` to get all packages in one install.\n\n## Support\n\nIf you find Allem SDK useful, consider supporting its development:\n\n<a href=\"https://buymeacoffee.com/kingofmit\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"50\" /></a>\n\n## License\n\n[MIT](https://github.com/kingofmit/allem-sdk/blob/main/LICENSE) - [Ahmed Allem](https://kingallem.com)\n","readmeFilename":"README.md","_rev":"1-c2fbba4524cb1758e5dfae2707241d76"}