@ngneat/hot-toast vs ngx-toastr
Angular Toast Notifications: Modern vs Legacy Implementation
@ngneat/hot-toastngx-toastrSimilar Packages:

Angular Toast Notifications: Modern vs Legacy Implementation

@ngneat/hot-toast and ngx-toastr are both popular libraries for displaying non-blocking notification popups in Angular applications. ngx-toastr is the legacy standard, known for its stability and extensive configuration options built around Angular modules. @ngneat/hot-toast is a modern alternative inspired by React's hot-toast, designed for standalone components, functional providers, and a simpler API surface. Both handle success, error, warning, and info states, but they differ significantly in setup, customization, and alignment with recent Angular versions.

Npm Package Weekly Downloads Trend

3 Years

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
@ngneat/hot-toast0-401 kB-2 years agoMIT
ngx-toastr02,588175 kB783 months agoMIT

Angular Toast Notifications: Modern vs Legacy Implementation

Both @ngneat/hot-toast and ngx-toastr solve the same problem — showing temporary feedback messages to users without blocking their workflow. However, they reflect different eras of Angular development. ngx-toastr represents the classic Module-based approach, while @ngneat/hot-toast embraces the modern Standalone and Functional API style. Let's compare how they handle setup, usage, and customization.

🛠️ Setup and Configuration

@ngneat/hot-toast uses functional providers, which fits cleanly into modern app.config.ts files.

  • You configure it once using provideHotToastConfig().
  • No need for NgModules in most cases.
// app.config.ts
import { provideHotToastConfig } from '@ngneat/hot-toast';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHotToastConfig({
      position: 'top-center',
      duration: 3000
    })
  ]
};

ngx-toastr relies on traditional NgModules and requires BrowserAnimationsModule.

  • You must import ToastrModule.forRoot() in your app module.
  • Requires extra setup for standalone apps.
// app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';

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

📢 Triggering Notifications

@ngneat/hot-toast uses a simple service object imported directly.

  • You call methods like toast.success() anywhere in your code.
  • No need to inject a service into constructors.
// component.ts
import { toast } from '@ngneat/hot-toast';

function saveData() {
  toast.success('Data saved successfully');
  // Or with options
  toast.error('Failed to save', { duration: 5000 });
}

ngx-toastr requires injecting the ToastrService into your class.

  • You call methods on the injected instance.
  • More boilerplate but explicit dependencies.
// component.ts
import { ToastrService } from 'ngx-toastr';

@Component({ ... })
export class MyComponent {
  constructor(private toastr: ToastrService) {}

  saveData() {
    this.toastr.success('Data saved successfully');
    // Or with options
    this.toastr.error('Failed to save', 'Error', { timeOut: 5000 });
  }
}

🎨 Custom Content and Components

@ngneat/hot-toast allows passing Angular components directly to the toast.

  • You can pass a component class and data inputs.
  • Great for complex notifications with buttons or forms.
// component.ts
import { toast } from '@ngneat/hot-toast';
import { CustomComponent } from './custom.component';

function showCustom() {
  toast.show(CustomComponent, {
    data: { message: 'Action required' },
    duration: 10000
  });
}

ngx-toastr typically uses TemplateRef or ComponentPortal.

  • You often need to define a template in your HTML first.
  • More verbose for custom UIs.
// component.ts
import { ToastrService } from 'ngx-toastr';
import { TemplateRef } from '@angular/core';

@Component({ ... })
export class MyComponent {
  constructor(private toastr: ToastrService) {}

  showCustom(templateRef: TemplateRef<any>) {
    this.toastr.show(templateRef, 'Custom Title', {
      toastClass: 'custom-toast'
    });
  }
}

📍 Positioning and Styling

@ngneat/hot-toast handles positioning via config objects.

  • Uses simple string values like 'top-center' or 'bottom-right'.
  • Styles are easily overridden via the style option.
// component.ts
import { toast } from '@ngneat/hot-toast';

toast.success('Moved to bottom', {
  position: 'bottom-center',
  style: { background: 'blue', color: 'white' }
});

ngx-toastr uses CSS classes for positioning.

  • You set classes like 'toast-top-right' in config.
  • Requires global CSS setup for custom themes.
// component.ts
import { ToastrService } from 'ngx-toastr';

this.toastr.success('Moved to bottom', '', {
  positionClass: 'toast-bottom-center',
  toastClass: 'blue-theme'
});

⏳ Loading States

@ngneat/hot-toast has built-in loading state management.

  • You can start a loader and resolve it later by ID.
  • Perfect for async operations like API calls.
// component.ts
import { toast } from '@ngneat/hot-toast';

async function loadData() {
  const loadingId = toast.load('Loading data...');
  
  try {
    await api.fetch();
    toast.success('Done', { id: loadingId });
  } catch {
    toast.error('Failed', { id: loadingId });
  }
}

ngx-toastr does not have built-in loading state transitions.

  • You must manually hide one toast and show another.
  • Requires tracking IDs manually if you want to replace them.
// component.ts
import { ToastrService } from 'ngx-toastr';

async function loadData() {
  const loading = this.toastr.info('Loading data...');
  
  try {
    await api.fetch();
    this.toastr.remove(loading.toastId);
    this.toastr.success('Done');
  } catch {
    this.toastr.remove(loading.toastId);
    this.toastr.error('Failed');
  }
}

🌱 Similarities: Shared Ground

While the implementation differs, both libraries share core goals and capabilities.

1. 📦 Standard Notification Types

  • Both support Success, Error, Warning, and Info out of the box.
  • Colors and icons are pre-configured for each type.
// @ngneat/hot-toast
toast.success('OK');
toast.error('Fail');

// ngx-toastr
this.toastr.success('OK');
this.toastr.error('Fail');

2. ⏱️ Auto-Dismissal

  • Both allow setting a duration before the toast disappears.
  • Users can often click to dismiss early.
// @ngneat/hot-toast
toast.show('Message', { duration: 4000 });

// ngx-toastr
this.toastr.show('Message', '', { timeOut: 4000 });

3. 🚫 Disable Auto-Close

  • Both support persistent toasts that stay until clicked.
  • Useful for critical errors requiring user acknowledgment.
// @ngneat/hot-toast
toast.error('Critical', { duration: 0 });

// ngx-toastr
this.toastr.error('Critical', '', { disableTimeOut: true });

4. ♿ Accessibility

  • Both use ARIA live regions to announce messages to screen readers.
  • Ensures compliance with basic accessibility standards.
// Both handle this internally via role="alert"
// No extra code needed for basic support

📊 Summary: Key Differences

Feature@ngneat/hot-toastngx-toastr
Setup🚀 Functional providers🧩 NgModules
Usage📦 Imported service object💉 Injected service
Custom UI🎨 Pass Component class🖼️ TemplateRef or Portal
Loading State✅ Built-in resolve/update❌ Manual remove/show
Styling🖌️ Inline style options🎭 CSS Classes
Modern Angular✅ Standalone ready⚠️ Requires adaptation

💡 The Big Picture

@ngneat/hot-toast is like a modern utility belt 🎒 — lightweight, easy to grab, and designed for speed. It removes boilerplate and fits naturally into new Angular projects. Choose this for greenfield development where you want less configuration and more code.

ngx-toastr is like a heavy-duty toolbox 🧰 — robust, familiar, and everywhere. It has been around for years and works reliably in complex enterprise apps. Choose this for maintaining existing systems or if your team prefers traditional dependency injection patterns.

Final Thought: Both libraries will get the job done, but @ngneat/hot-toast reduces friction for modern Angular developers. If you are starting fresh, the simpler API and standalone support make it the logical choice — unless you are already locked into the ngx-toastr ecosystem.

How to Choose: @ngneat/hot-toast vs ngx-toastr

  • @ngneat/hot-toast:

    Choose @ngneat/hot-toast if you are building a new Angular application using standalone components or recent versions (15+). It offers a simpler, function-based API that aligns with modern Angular practices like functional providers and signals. It is ideal for teams wanting less boilerplate and easier custom component integration without dealing with complex module imports.

  • ngx-toastr:

    Choose ngx-toastr if you are maintaining a legacy Angular application or need a battle-tested solution with a massive existing ecosystem. It is suitable for projects already using NgModules where migrating to a new notification system introduces unnecessary risk. It remains a solid choice for stable, long-term projects that do not require the latest Angular features.

README for @ngneat/hot-toast


npm MIT commitizen PRs styled with prettier styled with prettier All Contributors ngneat cypress semantic-release

Smoking hot Notifications for Angular. Lightweight, customizable and beautiful by default. Inspired from react-hot-toast

Compatibility with Angular Versions

@ngneat/hot-toastAngular
3.x >= 9.1.13 < 13
4.x >= 13 < 15
5.x >= 15 < 16
6.x >= 16

Features

  • 🔥 Hot by default
  • Easy to use
  • 🐍 Snackbar variation
  • Accessible
  • 🖐️ Reduce motion support
  • 😊 Emoji Support
  • 🛠 Customizable
  • Observable API
  • Pause on hover
  • 🔁 Events
  • 🔒 Persistent

Installation and setup

You can install it through Angular CLI:

ng add @ngneat/hot-toast

or with npm:

# For Angular version >= 9.1.13 < 13
npm install @ngneat/overview@2.0.2 @ngneat/hot-toast@3

# For Angular version >= 13 < 15
npm install @ngneat/overview@3.0.0 @ngneat/hot-toast@4

# For Angular version >= 15 <16
npm install @ngneat/overview@3.0.0 @ngneat/hot-toast@5

# For Angular version >= 16 <17
npm install @ngneat/overview@5.1.1 @ngneat/hot-toast@6

# For Angular version >= 17
npm install @ngneat/overview@6.0.0 @ngneat/hot-toast@7

Module Setup

This is taken care with ng add @ngneat/hot-toast

Now HotToastModule in your app.module. You can also set global toast options (Partial<ToastConfig>) here.:

import { HotToastModule } from '@ngneat/hot-toast';

@NgModule({
  imports: [HotToastModule.forRoot()],
})
class AppModule {}

Standalone Setup

import { AppComponent } from './src/app.component';

import { provideHotToastConfig } from '@ngneat/hot-toast';

bootstrapApplication(AppComponent, {
  providers: [
    provideHotToastConfig(), // @ngneat/hot-toast providers
  ]
});

Stylings

if you use SCSS add this line to your main styles.scss:

@use '@ngneat/hot-toast/src/styles/styles.scss';

or if you use CSS add this to your styles inside your angular.json:

"styles": [
     "node_modules/@ngneat/hot-toast/src/styles/styles.css",
],

Basic Usage

import { HotToastService } from '@ngneat/hot-toast';

@Component({})
export class AppComponent {
  constructor(private toast: HotToastService) {}

  showToast() {
    this.toast.show('Hello World!');
    this.toast.loading('Lazyyy...');
    this.toast.success('Yeah!!');
    this.toast.warning('Boo!');
    this.toast.error('Oh no!');
    this.toast.info('Something...');
  }

  update() {
    saveSettings
      .pipe(
        this.toast.observe({
          loading: 'Saving...',
          success: 'Settings saved!',
          error: 'Could not save.',
        })
      )
      .subscribe();
  }
}

You can pass ToastOptions while creating the toast to customize the look and behavior:

import { HotToastService } from '@ngneat/hot-toast';

@Component({})
export class AppComponent {
  constructor(private toast: HotToastService) {}

  customToast() {
    this.toast.success('Look at my styles, and I also need more time!', {
      duration: 5000,
      style: {
        border: '1px solid #713200',
        padding: '16px',
        color: '#713200',
      },
      iconTheme: {
        primary: '#713200',
        secondary: '#FFFAEE',
      },
    });
  }
}

You can also set global ToastConfig options while importing:

import { HotToastModule } from '@ngneat/hot-toast';

@NgModule({
  imports: [
    HotToastModule.forRoot({
      reverseOrder: true,
      dismissible: true,
      autoClose: false,
    }),
  ],
})
class AppModule {}

Additionally, you have the option of using a standalone function to provide a global toast configuration within your app's configuration file:

// app.config.ts
import { provideHotToastConfig } from '@ngneat/hot-toast';

export const appConfig: ApplicationConfig = {
  providers: [provideHotToastConfig({ ... })],
};

Examples

You can checkout examples at: https://ngneat.github.io/hot-toast#examples.

ToastConfig

All options, which are set Available in global config? from ToastOptions are supported. Below are extra configurable options:

NameTypeDescription
reverseOrderbooleanSets the reverse order for hot-toast stacking
Default: false
visibleToastsnumberSets the number of toasts visible. 0 will set no limit.
Default: 5
stacking"vertical"|"depth"Sets Sets the type of stacking
Default: "vertical"

ToastOptions

Configuration used when opening an hot-toast.

NameTypeDescriptionAvailable in global config?
idstringUnique id to associate with hot-toast. There can't be multiple hot-toasts opened with same id.
Example
No
durationnumberDuration in milliseconds after which hot-toast will be auto closed. Can be disabled via autoClose: false
Default: 3000, error = 4000, loading = 30000
Yes
autoClosebooleanAuto close hot-toast after duration
Default: true
Yes
positionToastPositionThe position to place the hot-toast.
Default: top-center
Example
Yes
dismissiblebooleanShow close button in hot-toast
Default: false
Example
Yes
roleToastRoleRole of the live region.
Default: status
Yes
ariaLiveToastAriaLivearia-live value for the live region.
Default: polite
Yes
themeToastThemeVisual appearance of hot-toast
Default: toast
Example
Yes
persist{ToastPersistConfig}Useful when you want to keep a persistance for toast based on ids, across sessions.
Example
No
iconContentIcon to show in the hot-toast
Example
Yes
iconThemeIconThemeUse this to change icon color
Example
Yes
classNamestringExtra CSS classes to be added to the hot toast container.Yes
attributesRecord<string, string>Extra attributes to be added to the hot toast container. Can be used for e2e tests.Yes
stylestyle objectExtra styles to apply for hot-toast.
Example
Yes
closeStylestyle objectExtra styles to apply for close buttonYes
dataDataTypeAllows you to pass data for your template and component. You can access the data using toastRef.data.
Examples: Template with Data, Component with Data
No
injectorInjectorAllows you to pass injector for your component.
Example
No

Supported Browsers

Latest versions of Chrome, Edge, Firefox and Safari are supported, with some known issues.

Accessibility

Hot-toast messages are announced via an aria-live region. By default, the polite setting is used. While polite is recommended, this can be customized by setting the ariaLive property of the ToastConfig or ToastOptions.

Focus is not, and should not be, moved to the hot-toast element. Moving the focus would be disruptive to a user in the middle of a workflow. It is recommended that, for any action offered in the hot-toast, the application offers the user an alternative way to perform the action. Alternative interactions are typically keyboard shortcuts or menu options. When the action is performed in this way, the hot-toast should be dismissed.

Hot-toasts that have an action available should be set autoClose: false, as to accommodate screen-reader users that want to navigate to the hot-toast element to activate the action.

Breaking Changes

2.0.2 -> 3.0.0

  • Content inside .hot-toast-message were wrapped into dynamic-content, now they are wrapped into div > dynamic-view
  • Use optional chaining while access toastRef in template. E.g. toastRef?.data
  • Add @Optional() decorator in components' constructor while injecting tokens which are used by toast's injector

4.1.0 -> 5.0.0

For this version you will also need to import the styles from the library like this if you're not using NgAdd

if you use SCSS add this line to your main styles.scss:

@use 'node_modules/@ngneat/hot-toast/src/styles/styles.scss';

or if you use CSS add this to your styles inside your angular.json:

"styles": [
     "node_modules/@ngneat/hot-toast/src/styles/styles.css",
],

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Dharmen Shah
Dharmen Shah

💻 🖋 🎨 📖 💡
Netanel Basal
Netanel Basal

🐛 💼 🤔 🚧 🧑‍🏫 📆 🔬 👀
Timo Lins
Timo Lins

🎨 🤔
Patrick Miller
Patrick Miller

🚧 📦
Gili Yaniv
Gili Yaniv

💻
Artur Androsovych
Artur Androsovych

🚧
Luis Castro
Luis Castro

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Icons made by Freepik from www.flaticon.com