canvas-confetti

A zero-dependency JavaScript library for firing performant, physics-based confetti animations on an HTML canvas.

Library
npm
v1.9.4
12,766 stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
47 /100 Fair
Development Activity 0
Maintenance 32
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
82 /100 Excellent
Architecture 82
Code Quality 78
Innovation 80
Learning Curve 88

canvas-confetti is a lightweight, dependency-free JavaScript library that renders celebratory confetti bursts on an HTML5 canvas. It exposes a single confetti() function with a rich set of physics parameters — particle count, angle, spread, velocity, gravity, drift, and decay — so a one-line call like confetti() produces a reasonable default burst while a fully-tuned call can drive multi-second, multi-origin animations.

Under the hood it reuses a single canvas element across calls, offloads rendering to a Web Worker with OffscreenCanvas when the browser supports it (falling back gracefully to the main thread), and supports custom shapes via SVG paths or rendered emoji/text. It also respects prefers-reduced-motion through an opt-in disableForReducedMotion flag, making it possible to add celebratory UI moments — checkout completions, form submissions, achievement unlocks — without pulling in an animation framework or paying much of a bundle-size or runtime-performance cost.

What You Get

  • A single confetti(options) function that returns a Promise resolving when the animation completes, so bursts can be sequenced or awaited
  • Fine-grained physics controls — particleCount, angle, spread, startVelocity, decay, gravity, drift, ticks, scalar, and origin coordinates — for tuning exactly how confetti behaves
  • Custom particle shapes via confetti.shapeFromPath (SVG path strings) and confetti.shapeFromText (emoji or text rendered as confetti), beyond the built-in square/circle/star shapes
  • A confetti.create(canvas, options) factory for scoping confetti to a specific canvas element instead of a full-page overlay, with optional automatic canvas resizing
  • Automatic Web Worker + OffscreenCanvas rendering when the browser supports it, falling back transparently to main-thread rendering elsewhere, plus a disableForReducedMotion option for accessibility
  • A prebuilt UMD/browser bundle (dist/confetti.browser.min.js) servable directly from a CDN like jsDelivr with zero build step required

Common Use Cases

  • Celebrating a successful checkout, signup, or payment completion in an e-commerce or SaaS flow
  • Rewarding users for hitting a milestone — completing an onboarding checklist, unlocking an achievement, or finishing a quiz
  • Adding a festive touch to New Year, birthday, or anniversary landing pages and countdown timers
  • Confirming a successful form submission or user action (e.g. “application submitted”) with a lightweight visual reward
  • Building confetti-cannon or fireworks-style interactive demos and game-over/victory screens

Under The Hood

Architecture: The entire library lives in a single UMD-style IIFE (src/confetti.js, ~880 lines) that detects at load time whether the browser supports Worker + OffscreenCanvas + transferControlToOffscreen, and if so lazily spins up a Web Worker running the same source (re-invoked via main.toString()) to do the actual per-frame canvas drawing off the main thread; otherwise it falls back to drawing directly on a lazily-created, reused <canvas> element positioned as a full-page fixed overlay. Animation state (particle positions, velocities, decay) is driven by a custom requestAnimationFrame scheduler (raf) that throttles to ~60fps and falls back to setTimeout when rAF is unavailable, and multiple concurrent confetti() calls are merged into the same in-flight animation rather than spawning competing loops.

Tech Stack: Runtime has zero dependencies — pure vanilla JavaScript targeting both <script>/CDN usage (UMD global confetti) and bundler usage (require/import, with module/jsdelivr build fields pointing at dist/confetti.module.mjs and dist/confetti.browser.js). The dev/build toolchain uses Browserify for bundling, Terser for minification, ESLint for linting, and a custom build/build.js script; tests run via AVA driving headless Puppeteer against a local static server, with Jimp used for pixel-level screenshot assertions.

Code Quality: The test suite (test/index.test.js, ~1250 lines, plus a dedicated ssr.test.js) exercises the library end-to-end in a real browser via Puppeteer rather than unit-testing internals in isolation, capturing and comparing rendered canvas output — a pragmatic choice for a purely visual library, though it means test correctness depends on Chromium rendering stability. Source code favors small, well-named internal closures (bitmapMapper, getWorker, raf) with inline comments explaining non-obvious browser-compatibility decisions (e.g. why bitmaps are cached, why disableForReducedMotion defaults to off), and defensive feature-detection guards every advanced code path (OffscreenCanvas, Path2D, DOMMatrix) with try/catch fallbacks so the library degrades rather than throwing on older browsers.

API Design: The public surface is deliberately minimal — a single callable confetti(options) plus three focused helpers (create, shapeFromPath, shapeFromText) — and every option has a sensible default, so confetti() with no arguments produces a usable result while power users can tune a dozen physics parameters. The README documents every option with type and default inline, and the Promise-based return value (with a pluggable confetti.Promise for legacy environments) makes sequencing multiple bursts straightforward without callback plumbing.

Used by 30 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 1 weeks ago
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

11,049

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
75
Repo Health
69
Technical
63
Dependency
Built with
TypeScript 92%
Updated 1 months ago
TypeScript
45%
AGPL 3.0

BrowserOS

AI Assistants · Browser

13,763

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 23%
Python 18%
Updated 1 weeks ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 1 weeks ago
Ruby
39%
AGPL 3.0

DocuSeal

Digital Signiture

18,629

Open source document signing platform with WYSIWYG PDF builder, multi-party workflows, REST API, and full self-hosting via Docker.

View details
87
Repo Health
80
Technical
69
Dependency
Built with
Ruby 39%
Vue 28%
HTML 20%
Updated 2 weeks ago
TypeScript
100%
Other

Dub

Analytics · Marketing

24,835

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
81
Repo Health
78
Technical
62
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
PHP
48%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,672

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
65
Dependency
Built with
PHP 48%
CSS 20%
Blade 17%
Updated 2 weeks ago
TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,166

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago

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