Ember CLI Notifications
Ember CLI Notifications is an Ember addon that provides Atom-inspired, transient notification messages for Ember applications. It enables developers to display various types of in-app alerts such as success, error, warning, and info messages, typically appearing at the top of the screen. The current stable version is 9.1.0, released in January 2025. This package generally follows a release cadence tied to Ember.js and Ember CLI updates, with major versions often introducing breaking changes to keep pace with the evolving Ember ecosystem, typically every 1-2 years. Key differentiators include its focus on a simple, injectable service for managing notifications, allowing programmatic control over message display, and offering customizable styling options. It integrates seamlessly into modern Ember applications, supporting Embroider and ember-auto-import v2.
Common errors
-
TypeError: Cannot read properties of undefined (reading 'success') (or similar for other notification types)
cause The `notifications` service has not been correctly injected or is not available in the current context.fixEnsure `import { inject as service } from '@ember/service';` is present and `@service notifications;` is used on the class property where you intend to use the service. -
Error: Could not find module `ember-cli-notifications/config/environment`
cause This usually indicates an issue with `ember-cli-notifications` not being correctly linked or built, or a cached `node_modules` issue.fixRun `ember install ember-cli-notifications` again. If that doesn't work, try clearing your `node_modules` and `tmp` directories (`rm -rf node_modules tmp && npm install`) and then rebuilding. -
DEPRECATION: Using the {{equals}} helper is deprecated.cause The `equals` helper was removed in v8.0.0. Your application or a dependency is still using it.fixRefactor your templates to use standard Ember template helpers for comparison (e.g., `{{if (eq this.value 'some-string')}}`) or update your dependencies.
Warnings
- breaking Version 9.0.0 transitioned to an Ember v2 addon format and dropped support for Ember.js versions older than 3.16.
- breaking Version 8.0.0 replaced overridable icon *paths* with overridable icon *components*, removed the obsolete `equals` helper, and dropped support for Node.js 10.
- breaking Version 7.0.0 dropped support for Node.js 8, Ember.js 2.18, and Ember.js 3.4.
- breaking Version 5.0.0 introduced significant changes including the removal of Font Awesome as a default dependency, renaming the notifications service to simply `notifications`, and removing CSS Modules.
- gotcha Notifications are transient by default. If `autoClear` is true, they will disappear after `clearDuration`. Set `autoClear: false` or `clearDuration: 0` for persistent notifications.
Install
-
npm install ember-cli-notifications -
yarn add ember-cli-notifications -
pnpm add ember-cli-notifications
Imports
- service
import service from '@ember/service';
import { inject as service } from '@ember/service'; - notifications
@service notification;
@service notifications;
- NotificationsService
import NotificationsService from 'ember-cli-notifications/services/notifications';
Quickstart
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@service notifications;
@action
showSuccessNotification() {
this.notifications.success('Operation successful!', {
autoClear: true,
clearDuration: 3000,
cssClasses: 'custom-success-class',
htmlContent: '<b>Successfully</b> completed action.'
});
}
@action
showErrorNotification() {
this.notifications.error('Something went wrong.', {
autoClear: false,
cssClasses: 'custom-error-class'
});
}
@action
showPersistentInfo() {
this.notifications.info('This is an informational message.', {
autoClear: false,
clearDuration: 0 // Will stay until manually cleared
});
}
@action
clearAllNotifications() {
this.notifications.clearAll();
}
}