question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to run nuxtClientInit after plugins initialized ?

See original GitHub issue

My client intialization code use plugins, and I got errors like this

TypeError: this.$myPlugin is not a function

It is possible to run nuxtClientInit after plugins initialized ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

4reactions
therealwolf42commented, Nov 9, 2019

I had a similar issue. Nuxt is supposed to load the modules in the order based on the nuxt.config file. However, in my case, the order was completely different. If you really need to wait for the initialization, the quickest way to achieve this, is to call emulate nuxtClientInit yourself.

For example:

https://github.com/therealwolf42/nuxt-socket.io-module/blob/master/lib/plugin.js#L20

plugin.js
export default async (context) => {
  if(process.browser) {
    // ... your code

    await context.store.dispatch('readySteadyGo', context)
  }
}
0reactions
timothymaroiscommented, Jan 13, 2021

The solution by @therealwolf42 successfully works in my case. Loaded it as a plugin and gives access to all the needed plugin variables in a custom init method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugins directory - Nuxt
The plugins directory contains your Javascript plugins that you want to run before instantiating the root Vue.js Application.
Read more >
Init nuxt plugins once instead of server + client - Stack Overflow
This works fine. However, both plugins are initialized twice, first from the server, then from the client, which I noticed because of 2...
Read more >
How to properly initialize app under SPA mode? #2660 - GitHub
I have an initialization issue using Nuxt on SPA mode. ... plugins (execute once before app loads); fetch (to init $store with server...
Read more >
Nuxt.js initialization - Mercari Engineering Blog
I'll use .nuxt-dev/client.js here, as it's easier to explain while looking at the code. The following code represents only what's needed to ...
Read more >
How to create a global custom plugin in Nuxt.js
Building the component · The store · Subscribe the component to the store · Initialize the plugin · Define and register the plugin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found