JavaScript
Lipi Lekhika offers a typesafe, tree-shakable package for JavaScript/TypeScript. It has support for all major javascript packaging formats namely ESM, CommonJS and UMD.
Installation
Section titled “Installation”bash npm install lipilekhika
bash pnpm add lipilekhika
bash bun add lipilekhika
bash yarn add lipilekhika
For transliteration use the transliterate function. Pass text as string | string[]; the result is a Promise<string> or Promise<string[]> with the same shape.
import { transliterate } from 'lipilekhika';
const result = await transliterate('na jAyatE mriyatE vA', 'Normal', 'Devanagari');console.log(result); // न जायते म्रियते वा- For commonjs you can use the
require('lipilekhika')syntax. - The Script/Language names are type safe so you will get editor support for autocompletion for names(including aliases).
- You can also pass in custom transliteration options to the
transliterateas the fourth argument to the function.
Web Assembly
Section titled “Web Assembly”The package includes a blazing-fast 🦀 Rust-based WASM implementation that works across all JavaScript environments (Node.js, browsers, Deno, Bun). Use transliterate_wasm() for improved performance and preloadWasm() to avoid initial loading delays.
Other Exports
Section titled “Other Exports”The package also exports the following constants and utilities:
SCRIPT_LIST— Array of all supported script namesLANG_LIST— Array of all supported language names mapped to scriptsALL_LANG_SCRIPT_LIST— Combined list of all supported scripts and languagespreloadScriptData(name)— Function to preload script data (useful for browsers to avoid fetch latency)getAllOptions(from, to)— Returns available custom transliteration options for a specific script pair
TypeScript Types:
TransliterationOptions— Type for custom transliteration optionsScriptListType/LangListType— Types for script and language listsScriptLangType— Type for script/language identifiers (with aliases)
Using Without a Package Manager
Section titled “Using Without a Package Manager”You can also use the package directly in the browser using the ESM and UMD Packages
ESM in Browser
Section titled “ESM in Browser”<script type="module"> import { transliterate } from 'https://cdn.jsdelivr.net/npm/lipilekhika/dist/esm/index.mjs'; transliterate('na jAyatE mriyatE vA', 'Normal', 'Devanagari').then((text) => console.log(text));</script>UMD in Browser
Section titled “UMD in Browser”<script src="https://cdn.jsdelivr.net/npm/lipilekhika"></script><script> lipilekhika .transliterate('na jAyatE mriyatE vA', 'Normal', 'Devanagari') .then((text) => console.log(text));</script>Typing Tool
Section titled “Typing Tool”For Browser environments we have a premade plugin for multiple frontend frameworks to use Lipi Lekhika’s realtime typing features.
An environment-agnostic reference guide to implement Realtime typing is any environment is available at the link below.
Node.js Native Module
Section titled “Node.js Native Module”The package also ships a native Rust-based N-API binding accessible via lipilekhika/node. This gives you near-native performance without the overhead of WASM instantiation.
import { transliterate_node, preloadNode } from 'lipilekhika/node';import { createTypingContext } from 'lipilekhika/node';
// Optional: preload the native moduleawait preloadNode();
const result = await transliterate_node('na jAyatE mriyatE vA', 'Normal', 'Devanagari');console.log(result); // न जायते म्रियते वा
// Typing context (same API as the TS version)const ctx = createTypingContext('Telugu');await ctx.ready;const diff = ctx.takeKeyInput('k');