vue-telegram icon indicating copy to clipboard operation
vue-telegram copied to clipboard

Integrate with nuxt 3

Open ZhulinskiiDanil opened this issue 1 year ago • 3 comments

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

ZhulinskiiDanil avatar Jan 20 '24 19:01 ZhulinskiiDanil

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?

deptyped avatar Jan 20 '24 22:01 deptyped

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

ZhulinskiiDanil avatar Jan 22 '24 20:01 ZhulinskiiDanil

Unfortunately, I don't have enough experience with nuxt and not sure how to implement it properly. PRs are welcome!

deptyped avatar Jan 25 '24 13:01 deptyped