I can't get snipcart to work with nuxt. "Tag #snipcart not found on the page"

Hello! New here.

I’m struggling making snipcart to work with nuxt. I get the error:

log

But the div is indeed on the page:

The api key is the one for testing.

I used this tutorial Building a Strapi E-Commerce with Nuxt.js [Tutorial] - Snipcart as reference, but with snipcart v3. The hidden div is on the default layout, and the scripts are in the nuxt.config. It is local development.

Any idea what I could be missing? Thanks ahead!

@rafael-lua

The api key seems to be added dynamically via javascript. This means the snipcart script might run before the api key was set. Setting the api key like so will fix your issue:

<template>
  <div>
    <nuxt />
    <div
      hidden
      id="snipcart"
      data-api-key="YOUR_API_KEY"
    ></div>
  </div>
</template>

Hi! The tutorial use this same snipped that you shared, which is the one I used as well:

But doesn’t seem to work.

I will try the https://snipcart.nuxtjs.org/ plugin and see how it goes.

EDIT: The plugin worked fine. Weird why didn’t work directly though.