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

231
Views
Setting up pinia persistent store on an individual web page

I have a simple vue js app and its only for one page only but i also want to access pinia stores when a i navigate to another page of the larger app.

I have setup vue 3, pinia and pinia persistent storage like this

<script src="https://unpkg.com/vue@3"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pinia/2.0.14/pinia.iife.js"></script>
<script src="https://unpkg.com/pinia-plugin-persistedstate-2"></script>

This works

const { createApp } = Vue

  createApp({
    data() {
      return {
        firstname: 'Hello Vue!'
      }
    }
  }).mount('#app')

Since pinia and pinia persistent state are available on the cdn, how can i port this to work entirely on the browser and can i access the stored data if i navigate to another browser page?

import { defineStore } from 'pinia'
import { createPersistedStatePlugin } from 'pinia-plugin-persistedstate-2'

export const useStore = defineStore('main', {
  state: () => {
    return {
      someState: 'hello pinia',
    }
  },
  persist: true,
})
about 4 years ago · Juan Pablo Isaza
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!