react-use-quicklink
v1.0.0
Published
[![Support me on Patreon](https://badgen.net/badge/become/a%20patron/F96854)](https://sdx.im/patreon) ![License MIT](https://badgen.net/github/license/sergiodxa/react-use-quicklink)
Downloads
2
Readme
react-use-quicklink
Quicklink hook for React. Run quicklink in your React application using a simple hook and prefetch all your links.
Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.
You'll need to install
react
,react-dom
, etc at^16.7.0-alpha.0
Installation
Install using yarn
yarn add react-use-quicklink
Or using npm
npm install --save react-use-quicklink
Usage
Import it as use it inside any React function component.
import useQuicklink from "react-use-quicklink";
function App() {
useQuicklink(); // this is all you need
return <UI />; // render some UI here with anchor tags to prefetch
}
That's all, now it will run quicklink. Aditionally you can pass a custom configuration as an object to the useQuicklink
hook.
import useQuicklink from "react-use-quicklink";
function App() {
useQuicklink({
origins: [
// add mine
"my-website.com",
"api.my-website.com",
// add third-parties
"other-website.com",
"example.com"
// ...
]
});
return <UI />;
}