Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

JoshuaKGoldberg/use-no-sleep

Repository files navigation

use-no-sleep

Code Style: Prettier TypeScript: Strict Circle CI

NoSleep.js, in React Hooks form. Use this hook to take your enabled state and translate it into NoSleep.js enable/disable calls.

Usage

Import with either a named or default export:

import { useNoSleep } from "use-no-sleep";
import useNoSleep from "use-no-sleep";

useNoSleep takes in a single parameter, enabled, of type boolean.

useNoSleep(enabled);

Internally, the NoSleep.js .enable() and .disable() calls are managed by a React useEffect.

FAQs

Why NoSleep.js?

The Wake Lock API is not yet standardized or ready for browsers to implement. Until then, NoSleep.js provides a workaround by playing a short silent video in the background.

Which NoSleep.js Version Does This Use?

This repository uses the ViRPo fork of the original richtr/NoSleep.js to help reduce CPU usage. See richtr/NoSleep.js#77.

Development

Thanks so much for contributing! 💖

Here are the steps to set this up locally: You probably want to develop with this locally:

git clone https://github.com/JoshuaKGoldberg/use-no-sleep
cd use-no-sleep
npm i

About

NoSleep.js, in React Hooks form 😴

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published