nuxt / scripts

Plug-and-play script optimization for Nuxt applications. (Public Preview)
https://scripts.nuxt.com
MIT License
126 stars 8 forks source link

Weird behaviour with lemonsqueezy script from registry #98

Open fayazara opened 1 week ago

fayazara commented 1 week ago

I am using the new nuxt/scripts module and a little confused. I want to enable the lemonsqueezy script globally, I have multiple pages where this is needed. How should I do this? the docs tell me to do the below and I added this in my app.vue

<script setup>
const { Setup } = useScriptLemonSqueezy();
onMounted(() => {
  Setup();
});
</script>

Whats happening

  1. index.vue pages opens the checkout overlay
  2. [...productId].vue pages open the checkout overlay if I open the page directly, but not when I navigate to this page from a <NuxtLink />

I thought this was an issue with the lemon.js script, but when I navigate to the product page from a NuxtLink, I can see window.LemonSqueezy has a been initiated which is confusing me even further, everything is working from both parties yet the checkout wont open in the overlay.

Here's a repro - https://stackblitz.com/edit/github-zk9jpe?file=pages%2Findex.vue

harlan-zw commented 1 week ago

Thanks for the details, I think this is what I also ran into when trying to implement the button (https://github.com/nuxt/scripts/issues/41). Will try and find the issue tomorrow.