@telegum/tgx
v0.3.2
Published
JSX runtime that renders Telegram messages content.
Downloads
234
Readme
Implementation of jsx-runtime
to create Telegram messages using JSX.
Installation
npm i @telegum/tgx
Then in your tsconfig.json
:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@telegum/tgx",
// ...
}
}
Example
Usage with grammY:
import { html } from '@telegum/tgx'
import { Bot } from 'grammy'
const Greeting = (props: { name: string }) => (
<>Hello, <b>{props.name}</b>!</>
)
const bot = new Bot(/* TOKEN */)
bot.command('start', async (ctx) => {
await ctx.reply(
html(<Greeting name={ctx.from.first_name} />),
{ parse_mode: 'HTML' }
)
})
bot.start()