Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
How can I integrate Vuex into a Storyblok plugin?

I'm building a plugin for storyblok with vue. I decided it would be easier to add state management to the plugin rather than an echo chamber of $emit() all the way back up the component tree. I installed Vuex into my plugin and went to add it to the main.js file as instructed in a Vuex tutorial however my main.js file isn't set up like a regular Vue app's main.js file.

The tutorial tells us to do this

import Vue from 'vue'
import App from './App.vue'
import store from './store' //our Vuex store

Vue.config.productionTip = false

new Vue({
    store, //passing in our store
    render: h =>(App)
}).$mount('#app')

However my main.js file due to being a storyblok plugin looks like this

import Plugin from './Plugin.vue'
import store from './store'  //I have no clue where to put this in the code below :(

if (process.env.NODE_ENV == 'development') {

  window.Fieldtype = Plugin
  let customComp = window.Storyblok.vue.extend(window.Fieldtype);
  window.Storyblok.vue.component('custom-plugin', customComp);
  window.StoryblokPluginRegistered = true;

} else {
  
  let init = Plugin.methods.initWith() 
  window.storyblok.field_types[init.plugin] = Plugin

}

As you can see the setup is totally different as it's geared towards injecting a Vue component into storyblok as a plugin rather than setting up a new Vue app. Does anybody know what I should do here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solve that issue adding in the main.js this line: window.Storyblok.vue.$store = store;

Then in your plugin when you call the store use the same. For example: window.Storyblok.vue.$store.commit()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!