I am building a library to be shared across my Nuxt projects the one thing I’m stuck with is for example my library contains the class
class MyLibrary {
setCredentials(creds) {
this.creds = creds;
}
getCredentials() {
return this.creds;
}
}
On the server side when I call setCredentials() and getCredentials() it returns fine, but after that when I do getCredentials() on the client side it returns undefined. What I gathered is that there are two instances of MyLibrary (class), one on the server and one on the client…
Is there a simple way to make sure both of them are sharing the same instance? It doesn’t work even if I inject it into nuxt and use it like this.$myLibrary.setCredentials()