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-powerglitch

v1.0.3

Published

<img src="./assets/intro.gif" alt="">

Downloads

1,410

Readme

React PowerGlitch

This React library is a wrapper around PowerGlitch. PowerGlitch is a standalone library with no external dependencies. It leverages CSS animations to glitch anything on the web, without using a canvas. It weights less than 2kb minified and gzipped.

Getting started

Install

  1. Install react-powerglitch using a package manager

    npm i --save react-powerglitch
    # or
    yarn add react-powerglitch
  2. Import the useGlitch hook from react-powerglitch anytime you want to use it.

    import { useGlitch } from 'react-powerglitch'

Glitch

In order to glitch something, call useGlitch() and store its result in a variable.

function App() {
    const glitch = useGlitch();

    return (
        <h1>react-powerglitch <span ref={glitch.ref}>🌎</span></h1>
    );
}

One limitation, when having the createContainers option set to true (which is the default), to not place the glitched element as the direct child of a component or a conditional rendering block. E.g. this will not work:

<>
    {/* Will not work */}
    {condition &&
        <span ref={glitch.ref}>🌎</span>
    }
</>

Instead, wrap the glitched element with a container:

<>
    {/* Will work */}
    {condition &&
        <div>
            <span ref={glitch.ref}>🌎</span>
        </div>
    }
</>

Customize

You can pass options to customize the glitch effect to useGlitch:

function App() {
    const glitch = useGlitch({ glitchTimeSpan: false });

    return (
        <h1>react-powerglitch <span ref={glitch.ref}>🌎</span></h1>
    );
}

The options props accept any value defined in the original PowerGlitch library.

Take a look at the playground to visually find out the best glitch options for your element.

Glitch controls

The useGlitch hook returns an object containing:

  • ref: A function ref which you should use on the element you want to glitch, as shown in previous sections.
  • startGlitch: Glitch control functions to start the glitch animation.
  • stopGlitch: Glitch control functions to stop the glitch animation.
  • setOptions: A function to change the glitch options. This will update the glitched element with the new options.

Here is an example:

function App() {
    const glitch = useGlitch({ glitchTimeSpan: false });

    return (
        <>
            <div>
                <h1 ref={glitch.ref}>react-powerglitch 🌎</h1>
            </div>
            <button onClick={glitch.startGlitch}>
                Start
            </button>
            <button onClick={glitch.stopGlitch}>
                Stop
            </button>
        </>
    );
}

TypeScript

The type GlitchHandle represents the return type of the useGlitch hook.

Your IDE should automatically identify the return type of useGlitch to be GlitchHandle and assign it to any variable you assign useGlitch() to. In case you want to statically use it, import GlitchHandle from react-powerglitch.

import { useGlitch, GlitchHandle } from 'react-powerglitch';

function App() {
    const glitch: GlitchHandle = useGlitch({ glitchTimeSpan: false });

    return (
        <>
            <div>
                <h1 ref={glitch.ref}>react-powerglitch 🌎</h1>
            </div>
            <button onClick={glitch.startGlitch}>
                Start
            </button>
            <button onClick={glitch.stopGlitch}>
                Stop
            </button>
        </>
    );
}