Laravel Nova & Vuex… a future proof solution?!

Miklós Galicz
Dec 7, 2018 · 2 min read

If you follow my stories, you probably know by now that I’ve got an ongoing fight to get Vuex properly working with my Laravel Nova admin site.

A quick recap

The first iteration was to attach a Vuex Store to the global object, which works… but not an ideal one…

The second trial was to modify the Source files for Nova to access the Root creation and append my Vuex store there. (This is a viable approach if you don’t install Nova through composer). This approach was quickly deprecated by version 1.1.9 which added Vuex, and since then some parts of Nova use it as well.

A solution?!

After Nova 1.2 we have a modular Vuex store available on the root instace (where it’s proper place is), and is accessible through the object! This enables us to do lots of “evil & nasty” things 😈

  1. You’ll need to install for your tool / resource tool
  2. In your tool’s file, on the life cycle event, you can dynamically register your store object with
  3. To use the store, you can access the state through the object, or (my favourite) the map helpers: , , …

This is a future proof method because the team probably won’t remove Vuex support in the future, and this is a supported, although little know way adding modules to the Vuex store.

It’s recommended that you namespace your modules to avoid collisions with other libraries!

Miklós Galicz

Written by

I am one of the lucky ones, who was able to turn a hobby into a way of living 😁