npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-firework

v1.2.0

Published

React Component - Firework Animation

Readme

React Firework


Table of Contents

Description

This is a React component that generates a fireworks animation using an HTML5 canvas.
You can customize several parameters to get the effect you prefer.


How to Use

Installation

npm i react-firework

Import

import { Firework, RandomFirework } from 'react-firework'

Add to your code

<Firework playExploud={play} />

Variables and Params

Firework props (canvas)

  • playExploud: boolean. Set to true to launch a firework explosion. When you set it back to false you can trigger a new launch. Default = false
  • amount: number. Amount of particles to be exploded in the fireworks. Default = 80
  • colors: string | string[]. Color or list of colors for the particles. You can pass RGB, HEX, HSL, HWB or text values. For example: 'rgb(0,0,255)', '#0000ff', 'hsl(240,100%,50%)', 'hwb(240,0,0)', or 'blue'. Default = ["red", "orange", "yellow"]
  • width: number. Canvas width in pixels. Default = 300
  • height: number. Canvas height in pixels. Default = 300
  • maxRadius: number. Maximum radius (size) of each particle in pixels. Default = 3
  • maxTime: number. Maximum life time of the particles in seconds. Default = 1.5
  • gravity: number. Gravity factor applied to particles movement (higher values make particles fall faster). Default = 0.0004

RandomFirework props

  • playExploud: boolean. When true, launches a sequence of random fireworks.
  • amountRandom: number. How many explosions to launch in that sequence. Default = 3
  • width: number. Canvas width in pixels. Default = 300
  • height: number. Canvas height in pixels. Default = 300

Example Code

import './styles.css'
import { Firework, RandomFirework } from 'react-firework'
import { useState } from 'react'

export default function App() {
  const [playSingle, setPlaySingle] = useState(false)
  const [playRandom, setPlayRandom] = useState(false)

  const handleSingle = () => {
    setPlaySingle(true)
    setTimeout(() => {
      setPlaySingle(false)
    }, 500)
  }

  const handleRandom = () => {
    setPlayRandom(true)
    setTimeout(() => {
      setPlayRandom(false)
    }, 500)
  }

  return (
    <div className='App'>
      <h1>React Firework (canvas)</h1>

      <button onClick={handleSingle}>Launch single firework</button>
      <Firework
        playExploud={playSingle}
        amount={150}
        colors={['#ffdd55', '#ff8800', '#ff4444']}
        width={400}
        height={400}
      />

      <button onClick={handleRandom}>Launch random sequence</button>
      <RandomFirework playExploud={playRandom} amountRandom={5} />
    </div>
  )
}

Fullscreen example (100% of the viewport)

If you want the firework to fill the whole screen, you can use the window size as the canvas size:

import { useState, useEffect } from 'react'
import { Firework } from 'react-firework'

export default function FullscreenFirework() {
  const [play, setPlay] = useState(false)
  const [size, setSize] = useState({
    w: window.innerWidth,
    h: window.innerHeight,
  })

  useEffect(() => {
    const onResize = () => {
      setSize({
        w: window.innerWidth,
        h: window.innerHeight,
      })
    }
    window.addEventListener('resize', onResize)
    return () => window.removeEventListener('resize', onResize)
  }, [])

  const handleClick = () => {
    setPlay(true)
    setTimeout(() => setPlay(false), 500)
  }

  return (
    <div
      style={{
        position: 'fixed',
        inset: 0,
        width: '100vw',
        height: '100vh',
        pointerEvents: 'none',
      }}
      onClick={handleClick}
    >
      <Firework
        playExploud={play}
        width={size.w}
        height={size.h}
        amount={200}
        colors={['#ffffff', '#ffdd55', '#ff4444']}
      />
    </div>
  )
}

Back To The Top


Find a bug

If you found an issue or would like to submit an improvement to this project, please submit an issue using the issues tab above. If you would like to submit a PR with a fix, reference the issue you created!


License

Copyright (c) [2023] [Nahuel Orselli]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back To The Top


Author Info

Nahuel Orselli Front end Developer.

Follow me

in LinkedIn as Nahuel Orselli

in Instagram as @nahuelorselli.jsx

in Twitter as @OrselliNahuel

in GitHub Nahuel Orselli

Back To The Top