use-read-time

    1.0.2 • Public • Published

    use-read-time

    React Hook to estimate read time for a provided text.

    NPM JavaScript Style Guide

    Install

    npm install --save use-read-time

    Usage

    import { useReadTime } from "use-read-time";
    
    const ExampleMinuteNumber = () => {
      const { readTime } = useReadTime({
        text: "Hello book with all but long paragraphs.",
      });
    
      console.log("ExampleMinuteNumber :: readTime", readTime); // 1
    
      return <h1>🤓 🔢</h1>;
    };
    import { useReadTime } from "use-read-time";
    
    const ExampleReadTimeLabel = () => {
      const { readTimeLabel } = useReadTime({
        text: "Hello book with all but long paragraphs.",
      });
    
      console.log("ExampleReadTimeLabel :: readTime", readTime); // Around 1 minute.
    
      return <h1>🤓 🏷️</h1>;
    };
    import { useReadTime } from "use-read-time";
    
    const ExampleReadTimeInfo = () => {
      const { readTimeLabel } = useReadTime({
        text: "Hello book with all but long paragraphs.",
      });
    
      console.log("ExampleReadTimeInfo :: readTimeInfo", readTimeInfo); // 1 min read
    
      return <h1>🤓 🗣</h1>;
    };

    API

    Field Type Description Required Default
    text String Text to calculate the amount of reading minutes for. yes
    speed Enum fast (240 wpm), normal (180 wpm), slow (100 wpm) - indicating the reading speed. no
    wpm Int Number representing the word per minute to calculate the estimate time to read. no 180

    License

    MIT © @ScottAgirs


    Credits

    Package by @ScottAgirs.

    This hook is created using create-react-hook.

    Install

    npm i use-read-time

    DownloadsWeekly Downloads

    10

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    504 kB

    Total Files

    20

    Last publish

    Collaborators

    • scottagirs