Skip to content

robiulalamdev/usebv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usebv

A simple React hook to detect browser visibility changes.

Installation

Install the package using npm:

npm install usebv

or using yarn:

yarn add usebv

Usage

Import the hook and use it in your React component:

import React from "react";
import useBv from "usebv";

const App = () => {
  const visibility = useBv();

  return (
    <div>
      <h1>Browser Visibility</h1>
      <p>Status: {visibility.status ? "Visible" : "Hidden"}</p>
      <p>Message: {visibility.message}</p>
    </div>
  );
};

export default App;

API

usebv()

Returns an object with the following properties:

  • status (boolean): true if the browser window is visible, false otherwise.
  • message (string): A message describing the visibility state.

Example Output

{
  "status": true,
  "message": "The browser window is currently open and visible."
}

License

MIT © robiulalamdev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors