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'constGreeting=(props)=>(<>Hello, <b>{props.name}</b>!</>)constbot=newBot(/* TOKEN */)bot.command('start',async(ctx)=>{awaitctx.reply(renderHtml(<Greetingname={ctx.from.first_name}/>),{parse_mode: 'HTML'})})bot.start()Usage with effect-tg:
import{Content,Dialog,Send,Text}from'effect-tg'constGreeting=(props)=>(<>Hello, <b>{props.name}</b>!</>)constgreet=(id,name)=>Send.sendMessage({dialog: Dialog.user(id),content: Content.text(Text.tgx(<Greetingname={name}/>))})
{ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "@grom.js/tgx"// "@grom/tgx" for JSR// ... } }