React component and hook to keep screen awake using Screen Wake Lock API.
npm install react-keep-awake
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>
)
}
npm ci
npm run dev