native-dates

Guides / Start

Installation

Add Native Dates in one command, with an optional polyfill for Safari and older Node releases.

Native Dates is an ES module package with bundled TypeScript types and zero runtime dependencies.

Install

Install from npm, or use the setup command if you work with a coding agent:

npm i native-dates
npx @native-dates/setup@latest

Then import from native-dates in your app:

app.js
import { date, now, today } from 'native-dates';

const due = today().plus(2, 'weeks');
const current = now('Europe/Berlin');
const standup = date('2026-11-16').at('9:30am', 'America/Los_Angeles');
standup.format('YYYY-MM-DD HH:mm'); // '2026-11-16 09:30'

Supporting Safari and older Node

Native Dates runs directly on the platform’s built-in Temporal and Intl APIs. Current releases of Chrome, Edge, Firefox, Node 26+, Deno, and Bun need nothing else.

For Safari, older browsers, or Node 22–25, install the polyfill alongside temporal-polyfill:

npm i @native-dates/polyfill temporal-polyfill

Import it once at the top of your entry file before loading date code:

main.js
import '@native-dates/polyfill';
import { today } from 'native-dates';

const launch = today().plus(30, 'days');

Zero cost on modern browsers

Runtimes with native Temporal and Intl.DurationFormat skip downloading either polyfill altogether.

Compatibility notes for older runtimes
  • Synchronous loading: If an imported module evaluates dates at load time before top-level await settles, import @native-dates/polyfill/sync instead.
  • Formatting durations on Node 22–23: @native-dates/polyfill includes a zero-dependency Intl.DurationFormat fallback so Duration.format() and Duration.text work on Node 22–23 as well (browsers and Node 24+ ship it natively and never download it).

Next, read Customization to tailor defaults and add optional plugins.

Edit this pageUpdated Nov 23, 2026