react-use-a2hs
v0.0.2
Published
Use Before Install Prompt Event with React Hooks
Downloads
118
Readme
react-use-a2hs
Access Before Install Prompt Event using React hooks.
Support Only Chrome and Edge.
How to use it
import React from "react";
import ReactDOM from "react-dom";
import { useA2HS } from "react-use-a2hs";
function App() {
const [promptEvent, promptToInstall] = useA2HS();
return (
<div className="App">
{promptEvent && (
<button onClick={promptToInstall}>{"please install PWA"}</button>
)}
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);