Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same issue in Nuxt as #46 but no vue-player #309

Open
Jamiewarb opened this issue Jan 30, 2024 · 1 comment
Open

Same issue in Nuxt as #46 but no vue-player #309

Jamiewarb opened this issue Jan 30, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@Jamiewarb
Copy link

There was an issue opened in #46 about Next.js and the liberal use of the Window object.

The resolve was a react-player. However, we have the same issues in Nuxt.

What workaround do we have for using dotlottie with Nuxt?

@afsalz afsalz self-assigned this Feb 16, 2024
@afsalz
Copy link
Contributor

afsalz commented Feb 16, 2024

Hi @Jamiewarb our dotlottie-player is not meant to run on server-side.

Here is how you can resolve this issue with nuxt

  1. create a plugin file.
    /plugins/lottie-player.js
import '@dotlottie/player-component';

export default () => {}; // keep this line
  1. Add it to nuxt.config.ts
  plugins: [{ src: "./plugins/lottie-player.js", mode: "client"}],
  vue: { 
    compilerOptions: { 
      isCustomElement: (tag) => tag.startsWith("dotlottie-player"), // Also tell vue its a custom component
    }
  }
  1. Use the player within a template
<template>
  <div>
    <dotlottie-player style="width: 500px; height: 500px;" src="https://lottie.host/5525262b-4e57-4f0a-8103-cfdaa7c8969e/VCYIkooYX8.json" autoplay loop />
  </div>
</template>

Please let us know if this works for you.

@afsalz afsalz added the question Further information is requested label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants