angular-notifier vs ngx-toastr
Choosing the Right Notification Library for Angular Applications
angular-notifierngx-toastrSimilar Packages:

Choosing the Right Notification Library for Angular Applications

angular-notifier and ngx-toastr are both popular libraries for displaying non-blocking notification messages (toasts) in Angular applications. angular-notifier is a modern, highly customizable library built specifically for Angular, offering extensive configuration options, multiple notification types, and a clean API that integrates well with Angular's dependency injection system. ngx-toastr is the Angular port of the widely-used toastr library, known for its simplicity, lightweight footprint, and familiar API for developers migrating from jQuery-based projects. Both libraries support standard notification types (success, error, warning, info) and provide mechanisms for programmatic control, but they differ significantly in architecture, customization capabilities, and maintenance status.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
angular-notifier02431.28 MB393 years agoMIT
ngx-toastr02,580175 kB787 months agoMIT

Angular Notification Libraries: angular-notifier vs ngx-toastr

When building professional Angular applications, displaying timely feedback to users through toast notifications is a common requirement. Two prominent solutions exist: angular-notifier and ngx-toastr. While both serve the same fundamental purpose, they differ significantly in architecture, customization capabilities, and long-term viability. Let's examine how they handle real-world scenarios.

🏗️ Architecture and Setup Approach

angular-notifier follows a modern Angular pattern with dedicated services and configuration tokens.

  • Requires importing the module with configuration options.
  • Uses a service-based API for triggering notifications.
  • Supports multiple notifier instances with different configurations.
// angular-notifier: Module setup
import { NotifierModule, NotifierOptions } from 'angular-notifier';

const customNotifierOptions: NotifierOptions = {
  behaviour: {
    autoHide: 5000,
    onClick: 'hide'
  },
  position: {
    horizontal: { position: 'right', distance: 12 },
    vertical: { position: 'top', distance: 12, gap: 10 }
  }
};

@NgModule({
  imports: [
    NotifierModule.withConfig(customNotifierOptions)
  ]
})
export class AppModule {}

ngx-toastr uses a simpler, more direct approach reminiscent of the original toastr library.

  • Import the module and animations module.
  • Inject the ToastrService directly into components.
  • Less boilerplate but fewer configuration options at the module level.
// ngx-toastr: Module setup
import { ToastrModule } from 'ngx-toastr';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  imports: [
    BrowserAnimationsModule,
    ToastrModule.forRoot({
      timeOut: 5000,
      positionClass: 'toast-top-right',
      preventDuplicates: true
    })
  ]
})
export class AppModule {}

🎨 Customization and Styling Flexibility

angular-notifier provides extensive theming capabilities through CSS variables and template customization.

  • Supports custom HTML templates for notifications.
  • Allows dynamic styling via configuration objects.
  • Offers built-in themes with easy override mechanisms.
// angular-notifier: Custom notification with template
this.notifierService.notify('custom', {
  title: 'Custom Alert',
  message: 'This uses a custom template',
  html: '<strong>Bold content</strong> with <em>emphasis</em>'
});

// In component template
<notifier-notification>
  <ng-template notifierNotificationTemplate let-notification>
    <div class="custom-toast">
      <h3>{{ notification.title }}</h3>
      <p>{{ notification.message }}</p>
    </div>
  </ng-template>
</notifier-notification>

ngx-toastr offers basic customization through configuration options but lacks template flexibility.

  • Limited to predefined toast types and positions.
  • Styling changes require CSS overrides rather than programmatic control.
  • No support for custom HTML content within toasts without risking security issues.
// ngx-toastr: Basic customization
this.toastr.success('Operation completed', 'Success', {
  timeOut: 3000,
  easing: 'ease-in',
  easeTime: 300
});

// CSS override required for custom styling
/* .toast-success { background-color: #custom-color !important; } */

🔄 Programmatic Control and Lifecycle Management

angular-notifier gives developers fine-grained control over individual notifications.

  • Each notification returns an observable for lifecycle tracking.
  • Supports hiding specific notifications by ID.
  • Allows pausing auto-hide timers on hover.
// angular-notifier: Lifecycle control
const notificationId = this.notifierService.notify('success', 'Processing...');

// Hide specific notification later
this.notifierService.hide(notificationId);

// Subscribe to hide events
this.notifierService.onHide().subscribe((id) => {
  console.log(`Notification ${id} was hidden`);
});

ngx-toastr provides simpler control mechanisms with less granularity.

  • Returns an individual toast reference with limited methods.
  • Global clear methods available but less precise control.
  • Fewer lifecycle hooks for advanced scenarios.
// ngx-toastr: Basic control
const toastRef = this.toastr.success('Task started');

// Hide specific toast
toastRef.onHidden.subscribe(() => {
  console.log('Toast was hidden');
});

// Clear all toasts
this.toastr.clear();

📍 Positioning and Layout Options

angular-notifier supports sophisticated positioning with gap management and responsive behavior.

  • Configurable horizontal and vertical positions independently.
  • Automatic gap calculation between multiple notifications.
  • Responsive adjustments based on viewport size.
// angular-notifier: Advanced positioning
const config: NotifierOptions = {
  position: {
    horizontal: { position: 'left', distance: 20 },
    vertical: { position: 'bottom', distance: 20, gap: 15 }
  }
};

ngx-toastr uses predefined position classes with limited flexibility.

  • Fixed position options (top-right, bottom-left, etc.).
  • No built-in gap management between toasts.
  • Requires manual CSS adjustments for complex layouts.
// ngx-toastr: Predefined positions
this.toastr.error('Something went wrong', 'Error', {
  positionClass: 'toast-bottom-left'
});

⚠️ Maintenance Status and Long-Term Viability

angular-notifier shows active maintenance with regular updates aligned to Angular versions.

  • Consistent release schedule with bug fixes and feature additions.
  • Strong TypeScript support with up-to-date type definitions.
  • Active community engagement and issue resolution.

ngx-toastr has exhibited reduced maintenance activity in recent periods.

  • Fewer updates addressing newer Angular versions.
  • Potential compatibility issues with latest Angular features.
  • Consider evaluating alternatives for long-term projects requiring stable support.

🌐 Real-World Implementation Scenarios

Scenario 1: Enterprise Dashboard with Complex Notifications

You need rich notifications with custom templates, progress indicators, and action buttons.

  • ✅ Best choice: angular-notifier
  • Why? Template customization and lifecycle control enable complex UI requirements.
// angular-notifier: Complex notification
this.notifierService.notify('info', {
  title: 'Data Export',
  message: 'Your report is being generated',
  html: `
    <div class="progress-container">
      <progress value="70" max="100"></progress>
      <button (click="cancelExport()">Cancel</button>
    </div>
  `
});

Scenario 2: Simple Admin Panel with Basic Feedback

You need quick success/error messages with minimal setup effort.

  • ✅ Best choice: ngx-toastr
  • Why? Simple API and low configuration overhead suit straightforward use cases.
// ngx-toastr: Simple feedback
this.toastr.success('Record saved successfully');
this.toastr.error('Failed to connect to server');

Scenario 3: Multi-Language Application with Dynamic Content

Your application requires notifications that adapt to different languages and contexts.

  • ✅ Best choice: angular-notifier
  • Why? Template support allows integration with translation pipes and dynamic content.
// angular-notifier: Dynamic content
this.notifierService.notify('warning', {
  title: this.translateService.instant('WARNING'),
  message: this.translateService.instant('SESSION_EXPIRING'),
  html: `<button>${this.translateService.instant('RENEW')}</button>`
});

📊 Feature Comparison Summary

Featureangular-notifierngx-toastr
Setup Complexity🧩 Moderate (configuration tokens)✅ Simple (direct service)
Custom Templates✅ Full HTML template support❌ Limited to text content
Position Control🎯 Granular (gap, distance, responsive)📍 Predefined classes only
Lifecycle Hooks🔄 Rich observables for events⚡ Basic onHidden/onShown
TypeScript Support💪 Excellent (modern types)👍 Good (established types)
Maintenance Status🟢 Active development🟡 Reduced recent activity
Bundle Size📦 Moderate📦 Lightweight

💡 Strategic Recommendations

Choose angular-notifier when:

  • Building new enterprise applications requiring robust notification systems
  • Need custom templates, progress indicators, or interactive elements in toasts
  • Require precise control over notification lifecycle and positioning
  • Prioritize long-term maintainability and active community support
  • Working with complex state management where notification tracking matters

Choose ngx-toastr when:

  • Maintaining legacy applications already using toastr patterns
  • Need simple success/error messages with minimal configuration
  • Project timeline demands quick implementation with familiar APIs
  • Bundle size is a critical constraint and basic functionality suffices
  • Team has existing expertise with the toastr ecosystem

🔮 Future-Proofing Considerations

For new projects starting today, angular-notifier presents a more sustainable choice due to its active maintenance cycle and alignment with modern Angular practices. Its architecture supports evolving requirements like custom templates, advanced positioning, and comprehensive lifecycle management – features increasingly expected in professional applications.

While ngx-toastr remains functional for basic use cases, teams should weigh the risks of potential compatibility issues with future Angular versions against the benefits of its simplicity. Consider prototyping with both libraries to evaluate which better fits your specific workflow before making a final architectural decision.

Both libraries solve the core problem effectively, but the choice ultimately depends on your project's complexity, timeline, and long-term maintenance strategy.

How to Choose: angular-notifier vs ngx-toastr

  • angular-notifier:

    Choose angular-notifier if you need a modern, actively maintained notification system with deep customization options, strong TypeScript support, and flexible positioning controls. It is ideal for new Angular projects where you require fine-grained control over notification behavior, styling, and lifecycle management. The library's architecture aligns well with current Angular best practices, making it suitable for enterprise applications that demand robustness and extensibility.

  • ngx-toastr:

    Choose ngx-toastr if you prioritize simplicity, minimal setup, and familiarity with the classic toastr API. It works well for smaller projects or teams migrating from legacy jQuery-based applications where consistency with existing patterns matters. However, be aware that this package has shown signs of reduced maintenance activity in recent years, so evaluate long-term support needs carefully before adopting it for critical production systems.

README for angular-notifier

angular-notifier

A well designed, fully animated, highly customizable, and easy-to-use notification library for your Angular 2+ application.



Demo

You can play around with this library with this Stackblitz right here.

Angular Notifier Animated Preview GIF




How to install

You can get angular-notifier via npm by either adding it as a new dependency to your package.json file and running npm install, or running the following command:

npm install angular-notifier

Angular versions

The following list describes the compatibility with Angular:

Angular NotifierAngularCompilation
1.x2.xView Engine
2.x4.xView Engine
3.x5.xView Engine
4.x6.xView Engine
5.x7.xView Engine
6.x8.xView Engine
7.x9.xView Engine
8.x10.xView Engine
9.x11.xView Engine
10.x12.xView Engine
11.x13.xIvy (partial mode)
12.x14.xIvy (partial mode)
13.x15.xIvy (partial mode)
14.x16.xIvy (partial mode)




How to setup

Before actually being able to use the angular-notifier library within our code, we have to first set it up within Angular, and also bring the styles into our project.


1. Import the NotifierModule

First of all, make angular-notifier globally available to your Angular application by importing (and optionally also configuring) the NotifierModule the your root Angular module. For example:

import { NotifierModule } from 'angular-notifier';

@NgModule({
  imports: [NotifierModule],
})
export class AppModule {}

But wait -- your probably might want to customize your notifications' look and behaviour according to your requirements and needs. To do so, call the withConfig method on the NotifierModule, and pass in the options. For example:

import { NotifierModule } from 'angular-notifier';

@NgModule({
  imports: [
    NotifierModule.withConfig({
      // Custom options in here
    }),
  ],
})
export class AppModule {}

2. Use the notifier-container component

In addition, you have to place the notifier-container component somewhere in your application, best at the last element of your root (app) component. For example:

@Component({
  selector: 'my-app',
  template: `
    <h1>Hello World</h1>
    <notifier-container></notifier-container>
  `,
})
export class AppComponent {}

Later on, this component will contain and manage all your applications' notifications.


3. Import the styles

Of course we also need to import the angular-notifier styles into our application. Depending on the architecture of your Angular application, you want to either import the original SASS files, or the already compiled CSS files instead - or none of them if you wish to write your own styles from scratch.

The easy way: Import all the styles

To import all the styles, simple include either the ~/angular-notifier/styles.(scss|css) file. It contains the core styles as well as all the themes and notification types.

The advanced way: Only import the styles actually needed

To keep the size if your styles as small as possible (improving performance for the perfect UX), your might instead decide to only import the styles actually needed by our application. The angular-notifier styles are modular:

  • The ~/angular-notifier/styles/core.(scss|css) file is always required, it defines the basic styles (such as the layout)
  • Themes can be imported from the ~/angular-notifier/styles/theme folder
  • The different notification types, then, can be imported from the ~/angular-notifier/styles/types folder




How to use

Using angular-notifier is as simple as it can get -- simple import and inject the NotifierService into every component (directive, service, ...) you want to use in. For example:

import { NotifierService } from 'angular-notifier';

@Component({
  // ...
})
export class MyAwesomeComponent {
  private readonly notifier: NotifierService;

  constructor(notifierService: NotifierService) {
    this.notifier = notifierService;
  }
}

Show notifications

Showing a notification is simple - all your need is a type, and a message to be displayed. For example:

this.notifier.notify('success', 'You are awesome! I mean it!');

You can further pass in a notification ID as the third (optional) argument. Essentially, such a notification ID is nothing more but a unique string tha can be used later on to gain access (and thus control) to this specific notification. For example:

this.notifier.notify('success', 'You are awesome! I mean it!', 'THAT_NOTIFICATION_ID');

For example, you might want to define a notification ID if you know that, at some point in the future, you will need to remove this exact notification.

The syntax above is actually just a shorthand version of the following:

this.notifier.show({
  type: 'success',
  message: 'You are awesome! I mean it!',
  id: 'THAT_NOTIFICATION_ID', // Again, this is optional
});

Hide notifications

You can also hide notifications. To hide a specific notification - assuming you've defined a notification ID when creating it, simply call:

this.notifier.hide('THAT_NOTIFICATION_ID');

Furthermore, your can hide the newest notification by calling:

this.notifier.hideNewest();

Or, your could hide the oldest notification:

this.notifier.hideOldest();

And, of course, it's also possible to hide all visible notifications at once:

this.notifier.hideAll();




How to customize

From the beginning, the angular-notifier library has been written with customizability in mind. The idea is that angular-notifier works the way your want it to, so that you can make it blend perfectly into the rest of your application. Still, the default configuration should already provide a great User Experience.

Keep in mind that angular-notifier can be configured only once - which is at the time you import the NotifierModule into your root (app) module.


Position

With the position property you can define where exactly notifications will appear on the screen:

position: {

  horizontal: {

    /**
     * Defines the horizontal position on the screen
     * @type {'left' | 'middle' | 'right'}
     */
    position: 'left',

    /**
     * Defines the horizontal distance to the screen edge (in px)
     * @type {number}
     */
    distance: 12

  },

  vertical: {

    /**
     * Defines the vertical position on the screen
     * @type {'top' | 'bottom'}
     */
    position: 'bottom',

    /**
     * Defines the vertical distance to the screen edge (in px)
     * @type {number}
     */
    distance: 12

    /**
     * Defines the vertical gap, existing between multiple notifications (in px)
     * @type {number}
     */
    gap: 10

  }

}

Theme

With the theme property you can change the overall look and feel of your notifications:

/**
 * Defines the notification theme, responsible for the Visual Design of notifications
 * @type {string}
 */
theme: 'material';

Theming in detail

Well, how does theming actually work? In the end, the value set for the theme property will be part of a class added to each notification when being created. For example, using material as the theme results in all notifications getting a class assigned named x-notifier__notification--material.

Everyone - yes, I'm looking at you - can use this mechanism to write custom notification themes and apply them via the theme property. For example on how to create a theme from scratch, just take a look at the themes coming along with this library (as for now only the material theme).


Behaviour

With the behaviour property you can define how notifications will behave in different situations:

behaviour: {

  /**
   * Defines whether each notification will hide itself automatically after a timeout passes
   * @type {number | false}
   */
  autoHide: 5000,

  /**
   * Defines what happens when someone clicks on a notification
   * @type {'hide' | false}
   */
  onClick: false,

  /**
   * Defines what happens when someone hovers over a notification
   * @type {'pauseAutoHide' | 'resetAutoHide' | false}
   */
  onMouseover: 'pauseAutoHide',

  /**
   * Defines whether the dismiss button is visible or not
   * @type {boolean}
   */
  showDismissButton: true,

  /**
   * Defines whether multiple notification will be stacked, and how high the stack limit is
   * @type {number | false}
   */
  stacking: 4

}

Custom Templates

If you need more control over how the inner HTML part of the notification looks like, either because your style-guide requires it, or for being able to add icons etc, then you can define a custom <ng-template> which you pass to the NotifierService.

You can define a custom ng-template as follows:

<ng-template #customNotification let-notificationData="notification">
  <my-custom-alert type="notificationData.type"> {{ notificationData.message }} </my-custom-alert>
</ng-template>

In this case you could wrap your own HTML, even a <my-custom-alert> component which you might use in your application. The notification data is passed in as a notification object, which you can reference inside the <ng-template> using the let- syntax.

Inside your component, you can then reference the <ng-template> by its template variable #customNotification using Angular's ViewChild:

import { ViewChild } from '@angular/core';

@Component({
  // ...
})
export class SomeComponent {
  @ViewChild('customNotification', { static: true }) customNotificationTmpl;

  constructor(private notifierService: NotifierService) {}

  showNotification() {
    this.notifier.show({
      message: 'Hi there!',
      type: 'info',
      template: this.customNotificationTmpl,
    });
  }
}

Animations

With the animations property your can define whether and how exactly notification will be animated:

animations: {

  /**
   * Defines whether all (!) animations are enabled or disabled
   * @type {boolean}
   */
  enabled: true,

  show: {

    /**
     * Defines the animation preset that will be used to animate a new notification in
     * @type {'fade' | 'slide'}
     */
    preset: 'slide',

    /**
     * Defines how long it will take to animate a new notification in (in ms)
     * @type {number}
     */
    speed: 300,

    /**
     * Defines which easing method will be used when animating a new notification in
     * @type {'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out'}
     */
    easing: 'ease'

  },

  hide: {

    /**
     * Defines the animation preset that will be used to animate a new notification out
     * @type {'fade' | 'slide'}
     */
    preset: 'fade',

    /**
     * Defines how long it will take to animate a new notification out (in ms)
     * @type {number}
     */
    speed: 300,

    /**
     * Defines which easing method will be used when animating a new notification out
     * @type {'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out'}
     */
    easing: 'ease',

    /**
     * Defines the animation offset used when hiding multiple notifications at once (in ms)
     * @type {number | false}
     */
    offset: 50

  },

  shift: {

    /**
     * Defines how long it will take to shift a notification around (in ms)
     * @type {number}
     */
    speed: 300,

    /**
     * Defines which easing method will be used when shifting a notification around
     * @type {string}
     */
    easing: 'ease' // All standard CSS easing methods work

  },

  /**
   * Defines the overall animation overlap, allowing for much smoother looking animations (in ms)
   * @type {number | false}
   */
  overlap: 150

}

In short -- the default configuration

To sum it up, the following is the default configuration (copy-paste-friendly):

const notifierDefaultOptions: NotifierOptions = {
  position: {
    horizontal: {
      position: 'left',
      distance: 12,
    },
    vertical: {
      position: 'bottom',
      distance: 12,
      gap: 10,
    },
  },
  theme: 'material',
  behaviour: {
    autoHide: 5000,
    onClick: false,
    onMouseover: 'pauseAutoHide',
    showDismissButton: true,
    stacking: 4,
  },
  animations: {
    enabled: true,
    show: {
      preset: 'slide',
      speed: 300,
      easing: 'ease',
    },
    hide: {
      preset: 'fade',
      speed: 300,
      easing: 'ease',
      offset: 50,
    },
    shift: {
      speed: 300,
      easing: 'ease',
    },
    overlap: 150,
  },
};