{"id":13809835,"url":"https://github.com/extend-chrome/notify","last_synced_at":"2025-05-08T19:36:52.370Z","repository":{"id":56538187,"uuid":"174019949","full_name":"extend-chrome/notify","owner":"extend-chrome","description":"Create notifications in your Chrome extension with ease.","archived":false,"fork":false,"pushed_at":"2023-10-16T22:00:18.000Z","size":662,"stargazers_count":12,"open_issues_count":8,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-04T10:38:45.170Z","etag":null,"topics":["chrome-extension","chrome-extensions","javascript","notifications","npm-module"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extend-chrome.png","metadata":{"funding":{"ko_fi":"jacksteam"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-05T21:00:48.000Z","updated_at":"2024-06-21T23:52:50.000Z","dependencies_parsed_at":"2024-01-13T14:41:45.051Z","dependency_job_id":"64924935-ca5a-471d-8e92-44181b5ac437","html_url":"https://github.com/extend-chrome/notify","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/extend-chrome%2Fnotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fnotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fnotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fnotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extend-chrome","download_url":"https://codeload.github.com/extend-chrome/notify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253135464,"owners_count":21859647,"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":["chrome-extension","chrome-extensions","javascript","notifications","npm-module"],"created_at":"2024-08-04T02:00:37.220Z","updated_at":"2025-05-08T19:36:52.343Z","avatar_url":"https://github.com/extend-chrome.png","language":"JavaScript","funding_links":["https://ko-fi.com/jacksteam"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003c!--\nTemplate tags:\nextend-chrome\nnotify\n@extend-chrome\nhttps://imgur.com/0lQYbgT.png\n--\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/extend-chrome/notify\" rel=\"noopener\"\u003e\n  \u003cimg width=200px height=200px src=\"https://i.imgur.com/HCX1Dpk.png\" alt=\"@extend-chrome/notify logo\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003e@extend-chrome/notify\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm (scoped)](https://img.shields.io/npm/v/@extend-chrome/notify.svg)](https://www.npmjs.com/package/@extend-chrome/notify)\n[![GitHub last commit](https://img.shields.io/github/last-commit/extend-chrome/notify.svg)](https://github.com/extend-chrome/notify)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\n[![TypeScript Declarations Included](https://img.shields.io/badge/types-TypeScript-informational)](#typescript)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Chrome Extension Tutorials on YouTube](https://img.shields.io/badge/Chrome%20Extension%20Tutorials-YouTube-c4302b.svg)](https://www.youtube.com/channel/UCVj3dGw75v8aHFYD6CL1tFg)\n[![ko-fi](https://img.shields.io/badge/Buy%20us%20a%20tea-ko--fi-29ABE0)](https://ko-fi.com/jacksteam)\n\n\u003c/div\u003e\n\n---\n\nThis is a simpler API for [`chrome.notifications`](https://developer.chrome.com/extensions/notifications) to use in Chrome extensions.\n\nAdd the [`notifications` permission](#permissions) and [create a notification](#usage) with as little as a string. `@extend-chrome/notify` will [do the rest](#manifest)! ✨\n\n```javascript\nnotify('This is too easy')\n```\n\n## Table of Contents\n\n- [Getting Started](#getting_started)\n- [Usage](#usage)\n- [Features](#features)\n- [API](#api)\n\n## Getting started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\n\nYou will need to use a bundler like [Rollup](https://rollupjs.org/guide/en/) or Webpack to include this library in the build of Chrome extension.\n\nSee [`rollup-plugin-chrome-extension`](https://github.com/extend-chrome/rollup-plugin-chrome-extension) for an easy way use Rollup to build your Chrome extension!\n\n### Installation\n\n```sh\n$ npm i @extend-chrome/notify\n```\n\n## Usage \u003ca name = \"usage\"\u003e\u003c/a\u003e\n\n```javascript\nimport { notify } from '@extend-chrome/notify'\n\nnotify('The most simple notification').then((id) =\u003e {\n  console.log('notification id', id)\n})\n\nnotify\n  .create({\n    message: 'You have been notified.',\n  })\n  .then((id) =\u003e {\n    console.log('notification id', id)\n  })\n```\n\nThe function `notify.create` takes any of the [official notification options](https://developer.chrome.com/extensions/notifications#type-NotificationOptions) for `chrome.notifications.create`, without trying to type `\"notifications\"` every time.\n\n### Permissions \u003ca name = \"permissions\"\u003e\u003c/a\u003e\n\nThe `\"notifications\"` permission must be included in `manifest.json`.\n\n```json\n// manifest.json\n{\n  \"permissions\": [\"notifications\"]\n}\n```\n\n## Features \u003ca name = \"features\"\u003e\u003c/a\u003e\n\n### TypeScript Definitions \u003ca name = \"typescript\"\u003e\u003c/a\u003e\n\nTypeScript definitions are included, so no need to install an additional `@types` library!\n\n### Gets Name and Icon from `manifest.json` \u003ca name = \"manifest\"\u003e\u003c/a\u003e\n\nThis library will use `chrome.runtime.getManifest()` to include the [name](https://developer.chrome.com/extensions/manifest/name#name) and [icon](https://developer.chrome.com/extensions/manifest/icons) of your extension in your notifications!\n\n## API \u003ca name = \"api\"\u003e\u003c/a\u003e\n\n### `notify(message: string)`\n\nReturns: `Promise\u003cstring\u003e`\n\nCreate a simple notification with an icon and the name of the Chrome extension, if they are supplied in `manifest.json`.\n\nReturns a promise which resolves to the notification id, which you can use in the `notify.onClick` and `notify.onButtonClick` events.\n\n```javascript\nconst myId = await notify('This is my notification')\n\nnotify.onClicked.addListener((clickedId) =\u003e {\n  if (myId === clickedId) {\n    console.log('My notification was clicked.')\n  }\n})\n```\n\n### `notify.create(options: NotificationOptions)`\n\nReturns: `Promise\u003cstring\u003e`\n\nCreate a [basic notification](https://developer.chrome.com/extensions/notifications#type-TemplateType) by default using as little as `options.message`, or any of the other properties in [NotificationOptions](https://developer.chrome.com/extensions/notifications#type-NotificationOptions).\n\nReturns a promise which resolves to the notification id, which you can use in [notification events](#api-events).\n\n```javascript\nconst myId = await notify.create({\n  message: 'This is my notification',\n})\n\nnotify.onClicked.addListener((clickedId) =\u003e {\n  if (myId === clickedId) {\n    console.log('My notification was clicked.')\n  }\n})\n```\n\n### Other methods and events\n\nAll the other methods and events from [`chrome.notifications`](https://developer.chrome.com/extensions/notifications) are promisified using [`chrome-promise`](https://github.com/tfoxy/chrome-promise) and assigned to `notify`, so you can use `notify` as if it is `chrome.notifications` with promises. These include the following:\n\n#### Methods \u003ca name = \"api-methods\"\u003e\u003c/a\u003e\n\nMethods return promises but are otherwise the same as the Chrome API.\n\n```javascript\nnotify\n  .update('my-notification', updateOptions)\n  .then((wasUpdated) =\u003e {\n    if (wasUpdated) {\n      console.log('my notification was updated')\n    }\n  })\n```\n\n- [`update(id) =\u003e Promise\u003cwasUpdated: boolean\u003e`](https://developer.chrome.com/extensions/notifications#method-update)\n- [`clear(id) =\u003e Promise\u003cwasCleared: boolean\u003e`](https://developer.chrome.com/extensions/notifications#method-clear)\n- [`getAll() =\u003e Promise\u003cnotificationIds: string[]\u003e`](https://developer.chrome.com/extensions/notifications#method-getAll)\n- [`getPermissionsLevel() =\u003e Promise\u003c'granted'|'denied'\u003e`](https://developer.chrome.com/extensions/notifications#method-getPermissionLevel)\n\n#### Events \u003ca name = \"api-events\"\u003e\u003c/a\u003e\n\nEvents are exacly the same as the Chrome API. Register a listener by calling `addListener` on an event:\n\n```javascript\nnotify.onClosed.addListener((id) =\u003e {\n  console.log('This notification was closed', id)\n})\n```\n\n- [`onClosed`](https://developer.chrome.com/extensions/notifications#event-onClosed)\n- [`onClicked`](https://developer.chrome.com/extensions/notifications#event-onClicked)\n- [`onButtonClicked`](https://developer.chrome.com/extensions/notifications#event-onButtonClicked)\n- [`onPermissionLevelChanged`](https://developer.chrome.com/extensions/notifications#event-onPermissionLevelChanged)\n- [`onShowSettings`](https://developer.chrome.com/extensions/notifications#event-onShowSettings)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextend-chrome%2Fnotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextend-chrome%2Fnotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextend-chrome%2Fnotify/lists"}