vue-telegram
vue-telegram copied to clipboard
Integrate with nuxt 3
Please! Integrate with nuxt 3
This works only if i write this:
<script setup lang="ts">
useHead({
script: [
{
src: 'https://telegram.org/js/telegram-web-app.js',
defer: true
}
]
})
onMounted(async () => {
const VueTg = await import('vue-tg')
})
<script>
If i write import without onMounted, nuxt throws error "Telegram is not defined"
because nuxt first render in server side
Hello. Telegram Mini App API exists only in Telegram app, so we can't render it on server side. How do you expect it to work?
Hello. Telegram Mini App API exists only in Telegram app, so we can't render it on server side. How do you expect it to work?
As an option on the server, avoid the error and return null so that you don’t have to write constructs using onMounted
Unfortunately, I don't have enough experience with nuxt and not sure how to implement it properly. PRs are welcome!