{"id":16978686,"url":"https://github.com/srph/react-notification","last_synced_at":"2026-05-17T03:45:18.169Z","repository":{"id":57162188,"uuid":"121831684","full_name":"srph/react-notification","owner":"srph","description":"Primitives to build your growls and dreams","archived":false,"fork":false,"pushed_at":"2018-06-11T04:59:45.000Z","size":59,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T06:06:32.750Z","etag":null,"topics":["notification","react","render-props","toast"],"latest_commit_sha":null,"homepage":"https://react-notification.kierb.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srph.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-17T06:01:39.000Z","updated_at":"2018-06-11T04:59:47.000Z","dependencies_parsed_at":"2022-09-10T02:33:11.052Z","dependency_job_id":null,"html_url":"https://github.com/srph/react-notification","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Freact-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Freact-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Freact-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Freact-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srph","download_url":"https://codeload.github.com/srph/react-notification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880550,"owners_count":20525511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notification","react","render-props","toast"],"created_at":"2024-10-14T01:44:00.565Z","updated_at":"2025-10-19T06:40:20.443Z","avatar_url":"https://github.com/srph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Notification [![npm version](https://img.shields.io/npm/v/@srph/react-notification.svg?style=flat-square)](https://npmjs.com/package/@srph/react-notification) [![Build Status](https://img.shields.io/travis/srph/react-notification.svg?style=flat-square)](https://travis-ci.org/srph/react-notification?branch=master)\n\nThis library provides you the *primitives* to create notifications like growl, snackbar, etc.\n\n[View examples](https://github.com/srph/react-notification/tree/master/storybook/stories) / [View demo](https://react-notification.kierb.com/)\n\n## Why should I pick this library?\n\n#### Pros\n- **Pick this up** if you're building a notification from scratch.\n- **Pick this up** if you want maximum customizability.\n- **Pick this up** if you want a small implementation ([68 LOC](https://github.com/srph/react-notification/blob/master/src/index.js)).\n\nBeing flexible means that you will spend time setting things up by yourself. Although, this library makes it painless ✨.\n\n#### Cons\n- **Pick something else** if you want styling out of the box.\n- **Pick something else** if you prefer a high-level implementation (like `type` or `placement`).\n\nHowever, my counter arguments are that: 1 - styling differs every organization, and customization is limiting or bloats a simple feature; and 2 - I think high-level features like `type` (errors, success) and `placement` (rarely the case) are simple to achieve with this library.\n\n## How It Works\nThis library uses the render props pattern. You can read more about it [here](https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce).\n\n## Installation\n```bash\nnpm install @srph/react-notification --save\n```\n\n### Script tags\nIf you're not using a bundler like Browserify or Webpack, simply add the script tag after your React script tag.\n\n```html\n\u003c!-- Script tags for React and other libraries --\u003e\n\u003cscript src=\"https://unpkg.com/@srph/react-notification/dist/react-notification.min.js\"\u003e\u003c/script\u003e\n```\n\nThis library is exposed as `ReactNotification` (e.g., `\u003cReactNotification.Notification /\u003e` and `ReactNotification.notify()`).\n\n## Usage\n```js\nimport React from 'react'\nimport {Notification, notify} from '@srph/react-notification'\n\nclass App extends React.Component {\n  render() {\n    return (\n      \u003cdiv\u003e\n        \u003cbutton onClick={() =\u003e notify({ text: 'Spawn something' })}\u003e\n          Go, go!\n        \u003c/button\u003e\n\n        \u003cNotification\u003e\n          {({items, onClose}) =\u003e (\n            items.map(item =\u003e (\n              \u003cdiv className='item' key={item}\u003e\n                {item.text}\n                \u003cbutton onClick={() =\u003e onClose(item.id)}\u003eClose\u003c/button\u003e\n              \u003c/div\u003e\n            ))\n          )}\n        \u003c/Notification\u003e\n      \u003c/div\u003e\n    )\n  }\n}\n\nexport default App;\n```\n\n\u003e Note: Mount `Notification` on your root (aka topmost) component.\n\n[View examples](https://github.com/srph/react-notification/tree/master/storybook/stories) / [View demo](https://react-notification.kierb.com/)\n\n## API Documentation\nHere's a list of props you may use to customize the component for your use-case:\n\n### `\u003cNotification /\u003e` Render Props\n| Parameter  | Type | Description |\n| ----- | ---- | ----------- |\n| items | `array` (`\u003cItem\u003e`) | Array containing the notifications. |\n| onClose | `function(id: Number)` | Removes the specific notification. Expects the id of an item. |\n\n#### `Item`\n```js\n{\n  id: Number,\n  text: String,\n  timeout: Number\n}\n```\n\n### `notify(opts: object)`\nUsed to spawn a new notification.\n\n| Parameter  | Type | Description |\n| ----- | ---- | ----------- |\n| `opts.text` | `string` (required) | The text of the notification. |\n| `opts.timeout` | `number` | Number of milliseconds before the toast is removed. Defaults to `10000` |\n\n\u003e Tip: You can do `notify('Hello')` which is the same as `notify({ text: 'Hello' })`.\n\n## Contributing\nBuild it yourself locally:\n\n```bash\nnpm install\nnpm run start\n```\n\nAfterwards, open up `localhost:9001` in your browser.\n\n### Bundling package\n```\nnpm run bundle\n```\n\n### Publish storybook\n```\nnpm run storybook:publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Freact-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrph%2Freact-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Freact-notification/lists"}