Install
pnpm add yugajsnpm install yugajsyarn add yugajsbun add yugajsimport { yuga } from "yugajs";
yuga().format("dddd, MMMM D");yugajs is ESM only: import it, there is no require build.
Requirements
Section titled “Requirements”yuga runs on the native Temporal and Intl APIs. It doesn’t bundle polyfills or look for them, so where an API is missing, load its polyfill once at the entry of your app, before anything imports yugajs.
| API | Native in | Polyfill |
|---|---|---|
Temporal |
Node.js 26+, Chromium 159, Firefox 159, Safari 27.2 | temporal-polyfill |
Intl.Locale#getWeekInfo |
Node.js 26+, Chromium 159, Firefox 159, Safari 27.2 | @formatjs/intl-locale |
The browser versions are the ones yuga’s tests run in. Earlier versions may have the APIs too.
// The entry of your app, before anything imports yugajs.import "temporal-polyfill/global"; // Defines `globalThis.Temporal` only when it's missing.import "@formatjs/intl-locale/polyfill.js"; // Installs itself only when `getWeekInfo` is missing.import { yuga } from "yugajs";Temporalis needed by parsing strings, time zones and anything that reads an instance’sTemporalvalue. Without it, importing yugajs works andyuga()still makes an instance, but those throw aReferenceError.Intl.Locale#getWeekInfois only needed by locales built from a language tag (yuga().locale("fr")), which read the first day of the week from it. A custom locale with its ownweekStartdoesn’t need it.
Parsing formats
Section titled “Parsing formats”Core parses ISO 8601 strings, Day.js’s loose YYYY-MM-DD HH:mm strings, dates, numbers and Temporal values. Strings in your own format need the custom-parse-format extension, the same as Day.js’s customParseFormat plugin:
import { yuga } from "yugajs";import { customParseFormat } from "yugajs/extension/custom-parse-format";
yuga.extend(customParseFormat);
yuga("15/05/2024", "DD/MM/YYYY");Every other extension installs the same way. See Extensions and plugins for the list.