react-use-quicklink

1.0.0 • Public • Published

react-use-quicklink

Support me on Patreon License MIT

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 />;
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-use-quicklink

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.94 kB

Total Files

5

Last publish

Collaborators

  • sergiodxa