Skip to content

Repository files navigation

tgx

npmjsr

JSX runtime for composing Telegram messages.

Installation

# Using npm
npm install @grom.js/tgx
# Using JSR
deno add jsr:@grom/tgx

Then in your tsconfig.json:

{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@grom.js/tgx"// "@grom/tgx" for JSR// ...
}
}

Examples

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}/>))})

License

MIT

About

✨ JSX runtime for composing Telegram messages.

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages