Installation
Requirements
- Node 18 or newer, if you run nepdate on a server or use a bundler.
- A modern browser for the components.
- TypeScript is optional. Types are included if you use it.
Choose your packages
Dates only
For a Node service, a script, or any code that only needs conversion and formatting:
npm install @nepdatejs/corepnpm add @nepdatejs/coreyarn add @nepdatejs/coreReact
npm install @nepdatejs/react @nepdatejs/stylespnpm add @nepdatejs/react @nepdatejs/stylesyarn add @nepdatejs/react @nepdatejs/stylesImport the stylesheet once, usually in your app's entry file:
import '@nepdatejs/styles';@nepdatejs/react needs React 18 or 19 as a peer dependency. It installs @nepdatejs/core for you, but add it to your own package.json if you import from it directly.
Vue, Svelte, Angular, or plain JavaScript with a bundler
These all use the Web Components:
npm install @nepdatejs/vanilla @nepdatejs/stylespnpm add @nepdatejs/vanilla @nepdatejs/stylesyarn add @nepdatejs/vanilla @nepdatejs/stylesThen register the elements once:
import '@nepdatejs/styles';
import '@nepdatejs/vanilla/define';A script tag, with no build step
For plain HTML, Laravel Blade, Django or Rails templates, add two lines to your page:
<link rel="stylesheet" href="https://unpkg.com/@nepdatejs/styles/index.css" />
<script src="https://unpkg.com/@nepdatejs/vanilla/dist/nepdate-picker.global.js"></script>See Script tag (CDN) for more, including pinning a version.
Optional packages
npm install @nepdatejs/holidays@nepdatejs/holidays adds Nepal's national holidays. To build your own UI, install @nepdatejs/calendar or @nepdatejs/datepicker directly.
PHP
composer require nepdatejs/nepdateThe PHP port of core for servers: see PHP (Composer).
Check that it works
Run this in Node, or anywhere you can import from @nepdatejs/core:
import { formatDate, today } from '@nepdatejs/core';
console.log(formatDate(today('BS'), 'full'));It prints today's date in BS, for example Sunday, 1 Kartik 2083.
TypeScript
Types come with each package. For the best experience, turn on strict in your tsconfig.json, which lets the compiler catch a BS date passed where an AD date is expected. The packages work with moduleResolution set to bundler, node16 or nodenext.