Lit-date is a lightweight (~1kB gzipped) and fast datetime formatter for modern browsers, using template literals for formatting. Version 1.0.5 is the current stable release. Unlike moment.js or date-fns, it uses tagged template literals (e.g., litdate`${'YYYY'}/${'MM'}/${'DD'}`(date)) and supports internationalization via custom functions. It is significantly faster than Moment.js and Day.js based on benchmarks. The library ships TypeScript types and supports both Node.js and browser environments via ESM or UMD bundles.
npm install lit-dateNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of lit-date with a template literal to format a Date object into a custom string pattern.
Ensure all placeholders are string literals: `${'YYYY'}` instead of `${year}`.Always call the result: litdate`...`(date).
Use a library like date-fns-tz if timezone support is needed.
Use import or dynamic import(). For CommonJS projects, consider using a bundler or switching to a compatible library.
Only include the format tokens you need; unused tokens add minimal size.
Replace variable placeholders with string literals: litdate`${'YYYY'}`.Change to import litdate from 'lit-date' or use dynamic import().
Add <script type="module"> and import litdate from the CDN URL.
Ensure the template literal is immediately invoked: litdate`${'YYYY'}`(new Date()).No dependency data recorded yet.