toastify-js

Lightweight, dependency-free vanilla JavaScript library for building customizable, stacked toast notifications.

Library
npm
v1.12.0
2,536stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
46/100Fair
Development Activity0
Maintenance20
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
46/100Fair
Architecture55
Code Quality25
Innovation50
Learning Curve55

Toastify is a lightweight, dependency-free JavaScript library for showing stacked, customizable toast notifications on any web page. It works as a plain <script> tag via CDN or as an ES module/CommonJS import, exposing a small imperative API (Toastify({...}).showToast()) that builds a positioned DOM node, supports click-to-navigate destinations, close buttons, avatars, and inline style overrides.

Because it has no framework dependency and ships both a UMD build (toastify.js) and an ES module build (toastify-es.js), it slots into vanilla JS pages, static sites, or any bundler-based frontend without extra tooling. The tradeoff is a frozen feature set: the library has seen no meaningful commits since mid-2024 and open issues have accumulated, so it suits simple, drop-in toast needs rather than actively evolving requirements.

What You Get

  • A single Toastify({...}).showToast() call that builds and inserts a positioned toast div into the DOM
  • Automatic stacking and repositioning of multiple simultaneous toasts via Toastify.reposition()
  • Built-in support for close buttons, avatars/icons, click-through destinations, and custom inline styles
  • Both a UMD bundle (src/toastify.js) for <script>/CommonJS use and an ES module build (src/toastify-es.js) for modern bundlers

Common Use Cases

  • Showing a ‘saved successfully’ or error confirmation toast after a form submission on a static or server-rendered page
  • Adding lightweight in-page notifications to a vanilla JS or jQuery-era project without pulling in a UI framework
  • Displaying a clickable toast that navigates the user to another URL when clicked (e.g. ‘view your order’)
  • Prototyping notification UX quickly via the CDN <script> tag before committing to a heavier component library

Under The Hood

Architecture Toastify is a single-file, prototype-based plugin: a factory function Toastify(options) returns new Toastify.lib.init(options), with Toastify.lib (aliased to Toastify.prototype) holding init, buildToast, showToast, hideToast, and removeElement, while module-level helpers (Toastify.reposition, getAxisOffsetAValue, containsClass) live outside the prototype chain in the same closure. State (this.options, this.toastElement) is held per-instance, but DOM construction, style application, event wiring, and positioning logic are all interleaved inside buildToast rather than separated into distinct layers, so extending behavior means editing that one function directly — adequate for the library’s narrow scope but not modular by design.

Tech Stack The package has zero runtime dependencies and no build tooling: src/toastify.js (UMD, for <script> tags and CommonJS) and src/toastify-es.js (a hand-maintained ES2022 class rewrite) are committed directly as the distributables, alongside a plain toastify.css. There is no bundler, transpiler, or TypeScript in the pipeline — package.json only declares metadata (main, license, repository) with no scripts/devDependencies, and distribution runs through npm plus the jsDelivr CDN referenced in the README.

Code Quality No test files or test framework exist anywhere in the repository; the legacy .travis.yml CI config explicitly runs echo "skipping tests" instead of a real test step. Error handling is minimal and untyped — buildToast/showToast throw plain strings (e.g. "Root element is not defined") rather than Error objects. There is no ESLint config (only a .prettierrc for formatting) and no CI beyond the deprecated, test-skipping Travis file. Naming is consistent and the code is commented reasonably well, but the absence of any automated verification is a real gap for a library embedded directly into consumers’ UIs.

API Design The public surface is a single chainable call, Toastify({ text, duration, gravity, position, ... }).showToast(), with a well-documented option table in the README covering every parameter, sensible defaults (e.g. duration: 3000, gravity: "top"), and a documented deprecation path (backgroundColorstyle.background). This keeps boilerplate low and the learning curve shallow, but the API itself — an options-object-plus-imperative-show call — is the same shape used by most toast libraries in the ecosystem (react-hot-toast, Notyf, iziToast) rather than anything novel.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search