I'm wondering if there is a nice way to have a UUID for a Vue JS 2 App.
I'm currently developing a Laravel API that is consumed by Android/IOS devices that identifies themselves by using the installation_id. Since it only changes on new app installation, it seems like the best approach for this purpose.
Now I have to develop the Vue JS app, but of course, there is no such thing. I've found this package but unfortunately, it only supports Vue JS 3: https://github.com/VitorLuizC/vue-uuid
Basically, what I need is to have uuid per app instance which persist on page refresh and even of hard refresh (not sure if possible at all) meaning clearing the app data from localStorage.
So far, I can only imagine creating a random uuid using this and storing it on localStorage, then on app mount check if this uuid exists on localStorage and if not, store it, otherwise just continue on.
import { v4 as uuidv4 } from 'uuid'
...
new Vue({
router,
mounted () {
if (!localStorage.getItem('installation_id')) {
localStorage.setItem('installation_id', uuidv4())
}
}
render: h => h(App)
}).$mount('#app')
I will appreciate any help to get the right path to achieve this.