Skip to main content

Command Palette

Search for a command to run...

How to create confetti in React JS

Published
•1 min read
How to create confetti in React JS
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

In this article, I will show you the easy and simple way to create confetti in React.

First, install the following dependency:

npm i canvas-confetti

After installing the above package, import it into your React application:

import confetti from 'canvas-confetti';

To create confetti using the package, create the following function:

const handleConfetti = () => {
    confetti();
 };

Now create a button with the onClick event:

<button onClick={handleConfetti}>Show Confetti</button>

This will create amazing and satisfying confetti 🎉.

Check out the live version:


Thanks for reading

Follow me on Twitter

Thanks for reading!

More from this blog

D

Dhairya Shah

119 posts