
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
use-stay-awake
Advanced tools
React hook that will help the device stay awake while actively using your website or app.
React hook that will help the device stay awake while actively using your website or app.
Using Yarn
yarn add --dev use-stay-awake
Using NPM
npm install --save use-stay-awake
import React from "react";
import useStayAwake from "use-stay-awake";
function App() {
const device = useStayAwake();
return (
<div>
<p>
Status:
<span>
{device.canSleep
? "Device is allowed to sleep"
: "Device is not allowed to sleep"}
</span>
</p>
<button
onClick={() => {
device.preventSleeping();
}}
>
Prevent Sleeping
</button>
<button
onClick={() => {
device.allowSleeping();
}}
>
Allow Sleeping
</button>
</div>
);
}
export default App;
Prop Name | Type | Description |
---|---|---|
canSleep | boolean default: true | Indicator if the device allowed to sleep. |
preventSleeping | function | Function that prevent the device from sleeping. |
allowSleeping | function | Function that allow the device from sleeping. |
v9-11
v12-84
v22-81
v4-87
v4-14-TP
v16-69
v3.2-14.0
v4.4-81
v12-46
v84
v68
v12.12
v4-12.0
v10.4
v7.12
v2.5
Thank you so much for contributing! :blue_heart:
Clone the repository
git clone https://github.com/roldanjr/use-stay-awake
Locate library folder
cd use-stay-awake
Install library dependencies
yarn install or npm install
Locate demo folder and install dependencies
cd demo
yarn install or npm install
Start development server under root folder
yarn develop or npm run develop
MIT © Roldan Montilla Jr
FAQs
React hook that will help the device stay awake while actively using your website or app.
The npm package use-stay-awake receives a total of 201 weekly downloads. As such, use-stay-awake popularity was classified as not popular.
We found that use-stay-awake demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.