# sveltegram

> Reactive Telegram widgets built with svelte

Latest version **2.0.11** (published 2026-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install sveltegram
pnpm add sveltegram
yarn add sveltegram
bun add sveltegram
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.11 |
| Published | 2026-05-19 |
| First published | 2022-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Amr |
| Maintainers | a3k |
| Keywords | svelte, sveltekit, telegram, post, comments, discussion, login, auth, widget, embed |

## Links

- npm: https://www.npmjs.com/package/sveltegram
- Repository: https://github.com/amr3k/sveltegram
- Homepage: https://sveltegram.a3k.me
- Issues: https://github.com/amr3k/sveltegram/issues
- npm.io page: https://npm.io/package/sveltegram

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 2.0.11 (latest) — 2026-05-19
- 2.0.10 — 2026-04-10
- 2.0.9 — 2026-04-07
- 2.0.8 — 2026-03-02
- 2.0.7 — 2026-02-20
- 2.0.6 — 2026-01-16
- 2.0.5 — 2025-09-10
- 2.0.4 — 2025-04-06
- 2.0.3 — 2025-03-31
- 2.0.2 — 2025-03-25
- 2.0.1 — 2025-01-23
- 2.0.0 — 2025-01-23
- 1.1.10 — 2024-02-21
- 1.1.9 — 2024-02-21
- 1.1.8 — 2023-12-06
- … 18 more at https://npm.io/package/sveltegram/versions

## README

# Sveltegram

This package allows you to embed telegram widgets in your svelte web application.

<div align="center">
  <img src="./images/Logo.svg" width="256px">

## [Demo & Documentation](https://sveltegram.a3k.me)

</div>

[![Demo](https://img.shields.io/website?label=Demo&url=https%3A%2F%2Fsveltegram.a3k.me)](https://sveltegram.a3k.me)
![GitHub branch checks state](https://img.shields.io/github/checks-status/amr3k/sveltegram/main)

<!-- ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/sveltegram) -->
<!-- ![npm](https://img.shields.io/npm/dw/sveltegram) -->
<!-- ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/amr3k/sveltegram?color=8e4700) -->

![LICENSE](https://img.shields.io/github/license/amr3k/sveltegram?style=flat&color=fcdaff)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/amr3k/sveltegram?color=fffc35&label=Repo%20size)
[![Hits-of-Code](https://hitsofcode.com/github/amr3k/sveltegram?branch=main)](https://hitsofcode.com/github/amr3k/sveltegram/view?branch=main)

- [Sveltegram](#sveltegram)
  - [Demo \& Documentation](#demo--documentation)
  - [Post widget](#post-widget)
    - [How to use](#how-to-use)
    - [API](#api)
  - [Discussions widget](#discussions-widget)
    - [How to use](#how-to-use-1)
    - [API](#api-1)
  - [Login widget](#login-widget)
    - [How to use](#how-to-use-2)
    - [API](#api-2)
- [Content Security Policy](#content-security-policy)
- [Limitations](#limitations)
- [Development](#development)
  - [Install](#install)
- [TODO](#todo)
- [License](#license)

## Post widget

Embed a telegram post widget in your svelte application.

### How to use

```js
<script>
  import { Post } from 'sveltegram';
</script>

<Post link="https://t.me/computly/439" />
```

### API

| Property              | Type    | Default   | Description                                            |
| --------------------- | ------- | --------- | ------------------------------------------------------ |
| `link` **(Required)** | string  |           | Telegram post link (_You can find it in context menu_) |
| `color`               | string  | `#2f81f6` | Accent color                                           |
| `colorDark`           | string  | `#89baff` | Accent color in dark mode                              |
| `darkMode`            | boolean | `false`   | Enable dark mode                                       |

## Discussions widget

Embed a telegram discussions widget in your svelte application.

### How to use

```js
<script>
  import { Discussions } from 'sveltegram';
</script>

<Discussions link="https://t.me/contest/198" />
```

### API

| Property              | Type    | Default   | Description                                                                                                                                                                                                             |
| --------------------- | ------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `link` **(Required)** | string  |           | Telegram discussions link (_You can find it in context menu_)                                                                                                                                                           |
| `pageURL`             | string  |           | If you want to auto load comments from your channel as explained in [Telegram documentation](https://core.telegram.org/widgets/discussion) You'll need to pass the same page URL as the one in `<link rel="canonical">` |
| `color`               | string  | `#2f81f6` | Accent color                                                                                                                                                                                                            |
| `colorDark`           | string  | `#89baff` | Accent color in dark mode                                                                                                                                                                                               |
| `darkMode`            | boolean | `false`   | Enable dark mode                                                                                                                                                                                                        |
| `colorfulNames`       | boolean | `false`   | Use different color for usernames                                                                                                                                                                                       |
| `commentsLimit`       | number  | `5`       | Number of comments to show                                                                                                                                                                                              |
| `height`              | number  |           | Height of the widget, The default value is 'auto' which is determined by Telegram                                                                                                                                       |

## Login widget

Embed a telegram login button in your svelte application.

### How to use

```js
<script>
  import { Login } from 'sveltegram';
</script>

<Login username="ComputlyBot" />
```

### API

| Property                                            | Type     | Default    | Description                                                                        |
| --------------------------------------------------- | -------- | ---------- | ---------------------------------------------------------------------------------- |
| `username` **(Required)**                           | string   |            | Your telegram bot username                                                         |
| `authType`                                          | string   | `callback` | How to authenticate users? Choices are [callback, redirect]                        |
| `redirectURL` **Required if `authType = redirect`** | string   |            | In case you chose redirect as an authentication method, you must set this property |
| `requestAccess`                                     | boolean  | `false`    | Whether you want to send messages to the user in the future                        |
| `size`                                              | string   | `medium`   | Login button size. choices are [small, medium,large]                               |
| `buttonRadius`                                      | number   | `10`       | Login button radius (in pixels)                                                    |
| `onauth` **(Required) if `authType = callback`**    | Function |            | Callback function responsible for handling successful authentication               |

# Content Security Policy

If you are using CSP, you'll need to allow scripts and iFrames coming from Telegram domains as follows:

```js
script-src https://telegram.org;
frame-src https://t.me;
```

# Limitations

- Can't use the same widget more than once due to telegram script assigning a unique id to each widget.

# Development

## Install

```sh
git clone https://github.com/amr3k/sveltegram.git
cd sveltegram
```

Then install dependencies:

```sh
pnpm install
```

# TODO

- [x] Add login widget
- [x] Migrate to svelte 5
- [x] Deploy demo to cloudflare
- [ ] Add [Share button widget](https://core.telegram.org/widgets/share)
- [ ] Publish to [jsr.io](https://jsr.io)

# License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/sveltegram · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
