react-keep-awake
v0.2.0
Published
React component and hook to keep screen awake.
Downloads
605
Maintainers
Readme
React keep awake
React component and hook to keep screen awake using Screen Wake Lock API.
Installation
npm install react-keep-awake
How to use
To keep screen awake by component:
import { KeepAwake } from 'react-keep-awake'
const MyApp = () => {
return (
<main>
<KeepAwake />
<p>Lorem ipsum</p>
</main>
)
}
To keep screen awake by hook:
import { useKeepAwake } from 'react-keep-awake'
const MyApp = () => {
useKeepAwake()
return (
<main>
<p>Lorem ipsum</p>
</main>
)
}
Development
npm ci
npm run dev