Skip to content

Adapter Overview & Comparison

useTemporal's adapter system allows you to use your preferred date library while maintaining a consistent API. Choose the adapter that best fits your project's needs.

Quick Comparison

AdapterBundle Size
(min+gzip)
Tree-shakeableTimezone
Support
Locale
Support
ImmutableMaintenance
Status
Native0KBActive
date-fns~2.1KBActive
date-fns-tz~2.5KBActive
Luxon~2.3KBActive
Temporal~3KBPolyfill

Performance Comparison

Performance benchmarks for common operations (operations per second on modern hardware):

OperationNativedate-fnsdate-fns-tzLuxonTemporal
Create Period1,200K980K940K420K380K
Divide Year→Months890K750K720K340K310K
Navigate (next/prev)1,100K920K890K380K350K
Date Math (add)1,050K880K850K360K330K

Note: Performance varies by environment. Run benchmarks on your target platform for accurate results.

Feature Matrix

FeatureNativedate-fnsdate-fns-tzLuxonTemporal
Core Operations
startOf/endOf
add/subtract
diff calculation
Advanced Features
Timezone conversion
DST handling
Locale formatting
Custom calendars
Developer Experience
TypeScript support
No dependencies
Immutable operations
Modular imports

When to Use Each Adapter

Native Adapter (Default)

Best for: Applications prioritizing bundle size and performance

Pros:

  • Zero dependencies
  • Fastest performance
  • Works everywhere
  • No configuration needed

Cons:

  • No timezone support
  • Limited formatting options
  • Basic functionality only

Use when:

  • Building lightweight applications
  • Working with local dates only
  • Bundle size is critical
  • You need maximum performance

date-fns Adapter

Best for: Applications needing rich date utilities without timezone complexity

Pros:

  • Excellent tree-shaking
  • Rich formatting/parsing
  • Extensive locale support
  • Well-documented

Cons:

  • No built-in timezone support
  • Requires peer dependency
  • Slightly larger than native

Use when:

  • You need advanced formatting
  • Locale support is important
  • Already using date-fns
  • Timezone isn't required

date-fns-tz Adapter

Best for: Applications already using date-fns that need timezone support

Pros:

  • Extends date-fns with timezone support
  • Familiar API for date-fns users
  • Good tree-shaking
  • Well-maintained

Cons:

  • Requires both date-fns and date-fns-tz
  • Slightly larger than plain date-fns
  • Less comprehensive than Luxon

Use when:

  • Already using date-fns
  • Need basic timezone support
  • Want to keep familiar API
  • Bundle size still matters

Luxon Adapter

Best for: Applications with international users and timezone requirements

Pros:

  • Full timezone support
  • Rich locale handling
  • Immutable by design
  • Handles DST correctly

Cons:

  • Larger bundle size
  • Slower than native/date-fns
  • More complex API

Use when:

  • Working with multiple timezones
  • Need robust DST handling
  • Building international apps
  • Data accuracy is critical

Temporal Adapter

Best for: Future-proofing and standards compliance

Pros:

  • Future JavaScript standard
  • Most precise calculations
  • Best timezone handling
  • Custom calendar support

Cons:

  • Currently requires polyfill
  • Larger bundle size
  • Still evolving

Use when:

  • Building new applications
  • Need maximum precision
  • Want future-proof code
  • Complex calendar requirements

Installation

Native (Included by default)

bash
npm install @allystudio/usetemporal

date-fns

bash
npm install @allystudio/usetemporal date-fns

date-fns-tz

bash
npm install @allystudio/usetemporal date-fns date-fns-tz

Luxon

bash
npm install @allystudio/usetemporal luxon

Temporal

bash
npm install @allystudio/usetemporal @js-temporal/polyfill

Quick Start Examples

Native (Default)

typescript
import { createTemporal } from '@allystudio/usetemporal'

const temporal = createTemporal()

date-fns

typescript
import { createTemporal } from '@allystudio/usetemporal'
import { createDateFnsAdapter } from '@allystudio/usetemporal/date-fns'

const temporal = createTemporal({
  adapter: createDateFnsAdapter()
})

date-fns-tz

typescript
import { createTemporal } from '@allystudio/usetemporal'
import { createDateFnsTzAdapter } from '@allystudio/usetemporal/date-fns-tz'

const temporal = createTemporal({
  adapter: createDateFnsTzAdapter({
    timezone: 'America/New_York'
  })
})

Luxon

typescript
import { createTemporal } from '@allystudio/usetemporal'
import { createLuxonAdapter } from '@allystudio/usetemporal/luxon'

const temporal = createTemporal({
  adapter: createLuxonAdapter({
    zone: 'America/New_York'
  })
})

Temporal

typescript
import { createTemporal } from '@allystudio/usetemporal'
import { createTemporalAdapter } from '@allystudio/usetemporal/temporal'

const temporal = createTemporal({
  adapter: createTemporalAdapter()
})

Next Steps

Released under the MIT License.