React Hook to estimate read time for a provided text.
npm install --save use-read-time
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>;
};
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 |
MIT © @ScottAgirs
Package by @ScottAgirs.
This hook is created using create-react-hook.