codekraft-studio / vue-record

VueJs components for MediaRecorder API
https://codekraft-studio.github.io/vue-record/
MIT License
94 stars 57 forks source link

Is it possible to use vue-record with NuxtJS? #18

Closed ChristianFenn closed 4 years ago

ChristianFenn commented 4 years ago

Hello, I'd love to use this in a NuxtJS application I'm building.

Currently when importing the component I'm seeing this in the terminal:

Screen Shot 2020-07-22 at 5 32 55 PM

I think this is basically saying Tone.js isn't supported in the browser, which is actually not even a browser, it's first rendering on the server side.

I'm importing it into my component as follows:

  import VueRecord from '@codekraft-studio/vue-record'

  export default {
    mixins: [authenticated],
    components: {
      // other components
      VueRecord,
    },
...

and the component used in the HTML section is like:

<client-only> <!-- client-only doesn't help here -->
    <VueRecordAudio @result="onResult" />
</client-only>

In the browser I get a 500 saying "document is not defined". Any ideas what I might be missing to use this in a NuxtJS application, or is the library not supported outside of vue-only applications?

hamidm21 commented 4 years ago

i have the same problem

hamidm21 commented 4 years ago

hi @NitroStoutPlz, i think i found the solution to this problem, this happens because the document object is not accessible for the package to work if you're using SSR within your nuxt app.

and to work around this you need to add .client.js at the end of your plugin file, according to this answer in stack overflow.

it worked for me, i hope it solves your problem too.

ChristianFenn commented 4 years ago

@hamidm21 Awesome! Thank you very much for letting me know about this 👍

hamidm21 commented 4 years ago

happy i could help. 🙏