@farhanmansuri/ignite-react
v2.0.0
Published
React hook for Ignite — pre-warms serverless functions on hover intent
Maintainers
Readme
@farhanmansuri/ignite-react
React hook for Ignite -- eliminates serverless cold starts by pre-warming functions on hover intent.
Install
npm install @farhanmansuri/ignite-react @farhanmansuri/ignite-coreUsage
Wrap your app with IgniteProvider, then use useIgnite in any component:
import { IgniteProvider, useIgnite } from '@farhanmansuri/ignite-react';
// In your app root
function App() {
return (
<IgniteProvider serverBaseURL="https://us-central1-myapp.cloudfunctions.net">
<CreateProjectButton />
</IgniteProvider>
);
}
// In any child component
function CreateProjectButton() {
const ignite = useIgnite('createProject');
return (
<button {...ignite} onClick={handleSubmit}>
Create Project
</button>
);
}Spreading {...ignite} attaches onMouseEnter, onMouseLeave, onFocus, and onTouchStart handlers automatically. When the user hovers for 150ms, a warm signal fires. By the time they click, the function is already warm.
