@vitella-ssr/pinia
v0.1.5
Published
A plugin to support Pinia in Vitella
Readme
@vitella-ssr/pinia
Pinia adapter for Vitella. Extends the Vue adapter with per-request Pinia state creation, automatic serialization of store state into window.__INITIAL_STATE__, and client-side hydration.
// vitella.config.ts
import { vitellaPlugin } from '@vitella-ssr/core'
import { piniaVueAdapter } from '@vitella-ssr/pinia'
export default {
plugins: [vitellaPlugin({
appShell: 'src/app.html',
adapter: piniaVueAdapter,
})],
}// src/stores/counter.ts
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', {
state: () => ({ count: 0 }),
})<!-- src/pages/index.vue -->
<script setup>
import { useCounterStore } from '../stores/counter'
const counter = useCounterStore()
counter.count++ // persisted and hydrated automatically
</script>