use-read-time
v1.0.3
Published
React Hook to estimate read time for a provided text.
Downloads
300
Maintainers
Readme
use-read-time
React Hook to estimate read time for a provided text.
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.