🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

temporal-react-hook

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporal-react-hook

A React library that provides hooks for handling date and time operations using the Temporal API

latest
Source
npmnpm
Version
2.2.2
Version published
Maintainers
1
Created
Source

temporal-react-hook

A modern React library that provides hooks for handling date and time operations using the Temporal API. This library makes it easy to work with dates, times, time zones, durations, and relative times in React applications.

Live Demo

Installation

npm install temporal-react-hook

or

yarn add temporal-react-hook

Available Hooks

HookDescription
useTemporalDateTimeGet and manage current date and time with configurable updates
useTimeZoneWork with time zones and convert between them
useDurationCreate and manipulate time durations, with comparison and formatting
useRelativeTimeFormat dates as human-readable relative times with localization
useLocaleDateTimeFormat dates according to locale-specific conventions
useTimeAgoDisplay how long ago a date occurred
useIsSameCompare if two dates are the same (day, month, year, etc.)
useIsBetweenCheck if a date falls within a specified date range (e.g., useIsBetween({ date, startDate, endDate }))
useDifferenceCalculate the numerical difference between two dates in a specified unit
useIsTodayCheck if a date is today
useIsThisWeekCheck if a date is in the current week
useIsThisMonthCheck if a date is in the current month
useIsThisYearCheck if a date is in the current year
useTemporalAddAdd time units to a date
useTemporalSubtractSubtract time units from a date
useTemporalFormatFormat dates with custom patterns
useTemporalStartOfGet the start of a time unit (day, week, month, etc.)
useTemporalEndOfGet the end of a time unit (day, week, month, etc.)
useTimeZoneOffsetGet the current UTC offset for a time zone, auto-updates on DST
useDateTimeRangeManage a date-time range with ordering, clamping, and helper functions
useGetDaysInYearGet the number of days in the year for a given date (365 or 366 for leap years)
useParseISOParse an ISO-8601 date-time string into a Temporal.PlainDateTime instance

Running the Demo Locally

# Clone the repository
git clone https://github.com/vlad-grigoryan/temporal-react-hook.git
cd temporal-react-hook

# Install dependencies
npm install

# Start the demo
cd demo
npm install
npm start

The demo will be available at http://localhost:5173/temporal-react-hook/

Why Temporal API?

The Temporal API is a modern JavaScript date/time API that addresses many of the shortcomings of the built-in Date object:

  • Immutable date/time objects
  • First-class time zone support
  • Calendar-aware date manipulation
  • Explicit handling of time zones and calendars
  • Clear distinction between wall-clock time and exact time

License

MIT

Keywords

react

FAQs

Package last updated on 21 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts