Skip to content

grom-dev/tgx

Repository files navigation

tgx

jsr npm

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

Example

Usage with grammY:

import { html } from '@grom.js/tgx'
import { Bot } from 'grammy'

function Greeting(props: { name: string }) {
  return <>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()

License

MIT

About

✨ JSX runtime for composing Telegram messages.

Topics

Resources

License

Stars

Watchers

Forks