https://github.com/bartlomiejzuber/use-cron-parser
Useful & super tiny (<5KB ✔️) hook for cron expression handling in React
https://github.com/bartlomiejzuber/use-cron-parser
cron hook parser react typescript
Last synced: about 2 months ago
JSON representation
Useful & super tiny (<5KB ✔️) hook for cron expression handling in React
- Host: GitHub
- URL: https://github.com/bartlomiejzuber/use-cron-parser
- Owner: bartlomiejzuber
- License: mit
- Created: 2021-08-22T08:22:49.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T15:49:49.000Z (over 4 years ago)
- Last Synced: 2025-09-20T16:03:42.696Z (9 months ago)
- Topics: cron, hook, parser, react, typescript
- Language: HTML
- Homepage:
- Size: 1.05 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## use-cron-parser


[](https://www.npmjs.com/package/use-cron-parser)
[](https://circleci.com/gh/bartlomiejzuber/use-cron-parser/tree/master)
[](https://github.com/bartlomiejzuber/use-cron-parser/blob/master/LICENSE)
[](https://app.netlify.com/sites/use-cron-parser-demo/deploys)
Useful & super tiny ( less than 5KB ✔️) (❤️obvious dep on React & single function from `date-fns`) hook to parse cron expression and get Date object with next cron occurrence.
## Installation
```sh
npm i use-cron-parser --save
```
Alternatively you may use `yarn`:
```sh
yarn add use-cron-parser
```
Link to npm:
[https://www.npmjs.com/package/use-cron-parser](https://www.npmjs.com/package/use-cron-parser)
## Usage
```javascript
import React from 'react';
import { useCronParser } from 'use-cron-parser';
const App = () => {
const cronExpression = "10 * * * *";
const cron = useCronParser(cronExpression);
return (
{cronExpression}
{cron.next()}
);
}
export default App;
```
[DEMO](https://use-cron-parser.netlify.app/)
## Hook params
| Parameter | Type | Description | Required |
|-----------|------------------------|---------------------------------------------------------|----------|
| cronExpression | string | Cron expression to parse | Y |
| options | useCronParserOptions | Set of hook options (skipValidation etc.) | N |
## Options
| Option | Description | Default |
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| skipValidation | Flag to skip/or not validation. | false |
Dependencies 
--------
Single function from `date-fns` package & ❤️obvious peer dep on React only.
Reliability
--------
This package is fully tested with total coverage set to [](https://coveralls.io/github/bartlomiejzuber/use-cron-parser). If you found any issue please report it [here](https://github.com/bartlomiejzuber/use-cron-parser/issues/new).
License
--------
Made with :sparkling_heart: by [Bartlomiej Zuber (bartlomiej.zuber@outlook.com)](mailto:bartlomiej.zuber@outlook.com) and licensed under the [MIT License](LICENSE)