JSX runtime for composing Telegram messages.
# Using npm
npm install @grom.js/tgx
# Using JSR
deno add jsr:@grom/tgxThen in your tsconfig.json:
Usage with grammY:
import { Bot } from 'grammy'
import { renderHtml } from '@grom.js/tgx'
const Greeting = (props) => (
<>Hello, <b>{props.name}</b>!</>
)
const bot = new Bot(/* TOKEN */)
bot.command('start', async (ctx) => {
await ctx.reply(
renderHtml(<Greeting name={ctx.from.first_name} />),
{ parse_mode: 'HTML' }
)
})
bot.start()Usage with effect-tg:
import { Content, Dialog, Send, Text } from 'effect-tg'
const Greeting = (props) => (
<>Hello, <b>{props.name}</b>!</>
)
const greet = (id, name) => Send.sendMessage({
dialog: Dialog.user(id),
content: Content.text(Text.tgx(<Greeting name={name} />))
})
{ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "@grom.js/tgx" // "@grom/tgx" for JSR // ... } }