Skip to content

Conversation

@SnehaKumari2005
Copy link

Title:
Update README with all usage methods for Aksharamukha.js

Description:
This pull request updates the README to provide a comprehensive guide for using Aksharamukha.js.

Changes include:

1)Plug-n-play browser usage via CDN
2)Node.js backend usage with ESM and CommonJS examples
3)Importing in frontend JS apps with modern bundlers (Vite, Webpack, Rollup)
4)React and Next.js client-side usage examples

@paramsiddharth paramsiddharth linked an issue Oct 21, 2025 that may be closed by this pull request
Copy link
Owner

@paramsiddharth paramsiddharth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions, some changes requested. Please take a look. Thank you!

Comment on lines +3 to +8
Aksharamukha in your browser and Node.js!

## Description
This project aspires to be a browser-compatible version of the [Aksharamukha](https://www.aksharamukha.com/) and its [Python library](https://github.com/virtualvinodh/aksharamukha-python), which is a transliteration tool for Indic scripts.
This project aspires to be a browser-compatible version of the [Aksharamukha](https://www.aksharamukha.com/) and its [Python library](https://github.com/virtualvinodh/aksharamukha-python), which is a transliteration tool for Indic scripts. The goal is to enable users to perform script conversions directly in their web browsers or Node.js applications without needing to rely on server-side processing.

The goal is to enable users to perform script conversions directly in their web browsers without needing to rely on server-side processing.
#### Aksharamukha.js can be used in multiple ways: directly in the browser via CDN, as a Node.js library, or imported in frontend JS apps using modern bundlers.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can mostly skip these changes. The goal and intention don't change – we just want to specify other ways the package can be used.

#### Aksharamukha.js can be used in multiple ways: directly in the browser via CDN, as a Node.js library, or imported in frontend JS apps using modern bundlers.

## Plug & Play
## 1. **Plug-n-Play(Browser via CDN)**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to bold the text or to add a numeral.

Suggested change
## 1. **Plug-n-Play(Browser via CDN)**
## Plug-&-Play (Browser via CDN)

</script>
</body>
</html>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code block not terminated here.

Suggested change
```

yarn add aksharamukha
```

ESM example (Node with "type": "module" or .mjs):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a level 3 header.

</html>


## 2. Node.js Usage
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


ESM example (Node with "type": "module" or .mjs):

> **Note:** Top-level `await` requires Node.js v14.8+ and `"type": "module"` in your `package.json`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mention this. :) This is irrelevant to the package.

Comment on lines +72 to +75
Notes:
- Wrap usage in an async function (or use top-level await where supported).
- Choose ESM vs CommonJS according to your project's configuration.
- Check your Node version and bundler settings if you encounter import issues.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be skipped for the same reason.

Comment on lines +76 to +117
## 3. Import in JS apps

Install the package for your app:

```bash
# npm
npm install aksharamukha

# yarn
yarn add aksharamukha

# pnpm
pnpm add aksharamukha
```

Basic ESM usage (bundlers like Vite, Webpack, Rollup):

```javascript
// src/main.js
import Aksharamukha from 'aksharamukha';

async function run() {
const ak = await Aksharamukha.new();
const out = await ak.process('autodetect', 'Devanagari', 'namaste');
console.log(out);
}

run().catch(console.error);
```

CommonJS usage:

```javascript
// src/main.cjs
const Aksharamukha = require('aksharamukha');

(async () => {
const ak = await Aksharamukha.new();
console.log(await ak.process('autodetect', 'Malayalam', 'śrī'));
})().catch(console.error);
```

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated, I think.

Comment on lines +142 to +158
Next.js note:
- Use the component client-side only (disable SSR) if the package relies on browser APIs or WASM. Example:

```javascript
// pages/index.js (Next.js)
import dynamic from 'next/dynamic';
const TransliterateClient = dynamic(() => import('../components/TransliterateClient'), { ssr: false });

export default function Page() {
return <TransliterateClient text="praNAm." />;
}
```

Bundler / WASM considerations:
- If the package includes a WASM asset, ensure your bundler is configured to load it (Vite/webpack may need asset rules or a plugin). If you encounter import errors, check your bundler docs for handling .wasm and async module initialization.
That’s it — import normally according to your project's module system and run Aksharamukha.new() before calling process().

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed at the moment, either.

Comment on lines +118 to +140
React (client-side) example:

```jsx
// components/TransliterateClient.jsx
import React, { useEffect, useState } from 'react';
import Aksharamukha from 'aksharamukha';

export default function TransliterateClient({ text }) {
const [out, setOut] = useState('');

useEffect(() => {
let alive = true;
(async () => {
const ak = await Aksharamukha.new();
const result = await ak.process('autodetect', 'Tamil', text);
if (alive) setOut(result);
})();
return () => { alive = false; };
}, [text]);

return <div>{out}</div>;
}
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the relevance of alive here? Also, please use React Fragments instead of the div in this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update README with all ways to use the library

2 participants