Skip to content

About

Telegram Login for Nuxt. A Nuxt module with a login button, OpenID Connect redirect and sealed session cookies checked on the server.

Topics

Resources

Contributing

Security policy

Stars

35 stars

Watchers

1 watching

Forks

Repository files navigation

nuxt-telegram-auth logo

🔐 Telegram login for Nuxt. A Nuxt auth module with Telegram's login widget, a popup button and the OAuth (OpenID Connect) redirect, with the session checked and sealed on the server.


npm version npm downloads npm monthly downloads CI License Nuxt version GitHub sponsors

Documentation

  • 😌 Telegram Login - A popup button or the OpenID Connect redirect, checked on the server
  • 🔒 Sealed Sessions - One HttpOnly session cookie for every login method, no database needed
  • 🛡️ Pages and Routes - definePageMeta({ telegramAuth: true }) for pages, requireTelegramSession(event) for your API
  • 🪝 Hooks - Save users, add roles or refuse a login from a server hook

Installation:

npx nuxi module add nuxt-telegram-auth

Turn on Telegram Login for your bot in the @BotFather Mini App (Bot Settings → Login Widget), add your site to Allowed URLs, and put the client ID and a session secret in .env:

NUXT_PUBLIC_TELEGRAM_AUTH_CLIENT_ID=123456789
NUXT_APP_SECRET=at-least-32-random-characters

After that you can try it on a page:

<template>
  <div v-if="loggedIn">
    <p>Hey {{ user?.first_name }}, you are logged in!</p>
    <button @click="clear">Logout</button>
  </div>
  <TelegramLoginButton v-else />
</template>

<script setup lang="ts">
const { user, loggedIn, clear } = useTelegramSession();
</script>

See the documentation for the redirect login, hooks, page protection, the classic login widget and upgrading from 1.x.

Found a bug or have an idea? Open an issue.
Read the contributing guide before sending a pull request.

MIT LICENSE | Halit Sever

About

Telegram Login for Nuxt. A Nuxt module with a login button, OpenID Connect redirect and sealed session cookies checked on the server.

Topics

Resources

Contributing

Security policy

Stars

35 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages