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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mouse-follow

v1.0.2

Published

A React hook to make elements follow or move away from the mouse cursor.

Downloads

10

Readme

🐭 mouse-follow

A React hook that enables elements to follow or move away from the mouse cursor, enhancing user interaction with dynamic cursor effects.

npm GitHub GitHub stars

Project Screenshot

✨ Features

  • Dynamic Cursor Interaction: Effortlessly make elements follow or repel the mouse cursor. 🖱️
  • Customizable Behavior: Easily adjust settings to fit your application's needs. 🛠️
  • Lightweight and Efficient: Designed with performance in mind to ensure smooth user experiences. ⚡

📦 Installation

Install the package using npm:

npm install mouse-follow

Or with yarn:

yarn add mouse-follow

🚀 Usage

First, import the useMouseFollow hook into your React component:

import useMouseFollow from 'mouse-follow';

Then, apply the hook to your component:

import React from 'react';
import { useRef } from 'react'
import useMouseFollow from 'mouse-follow';

const FollowExample = () => {
const ref = useRef<HTMLDivElement>(null)
    useMouseFollow(ref, {
    boundaryX?: number, // Boundary width (default: element width) ex. 200
    boundaryY?: number, // Boundary height (default: element height) ex. 300
    duration?: number, // Time (in ms) for the element to return to its original position (default: 1000ms) 1500
    follow?: boolean, // Whether the element follows the mouse or moves away (default: true)

  return (
    <div ref={ref}>
      {/* Your content */}
    </div>
  );
};

export default YourComponent;

⚙️ Configuration Options

The useMouseFollow hook accepts an optional configuration object with the following properties:

| Property | Type | Description | Default | |----------|---------|-----------------------------------------------------------------------------|---------| | follow | boolean | If true, the element follows the cursor; if false, the element moves away from the cursor. | true | | duration | number | Determines the time (in milliseconds) it takes for the element to return to its original position. A lower value results in faster movement. | 1000 | | boundaryX | number | Boundary width for the element's movement. If not provided, defaults to the element's width. | undefined | | boundaryY | number | Boundary height for the element's movement. If not provided, defaults to the element's height. | undefined |

🎯 Example

Here's a simple example demonstrating how to use mouse-follow:

import React from 'react';
import { useRef } from 'react'
import useMouseFollow from 'mouse-follow';

const FollowExample = () => {
const divRef = useRef<HTMLDivElement>(null)
    useMouseFollow(divRef, {
    boundaryX: 400,
    boundaryY: 400,
    duration: 2000,
    follow: true,
  })

  return (
    <div
      ref={divRef}
       style={{
        width: '50px',
        height: '50px',
        backgroundColor: 'blue',
        borderRadius: '50%',
        position: 'absolute',
      }}
    />
  );
};

export default FollowExample;

In this example, a blue circle will smoothly follow the mouse cursor around the screen. 🖱️💙

🤝 Contributing

Contributions are welcome! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request on the GitHub repository.

Steps to Contribute:

  1. Fork the repository. 🍴
  2. Create a new branch for your feature or bugfix. 🌿
  3. Commit your changes. 💾
  4. Push your branch and submit a pull request. 🚀

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


Made with ❤️ by Ahmed Elkhdrawy.