Runable v1.0.0-alpha.20
Why Runable? Docs Modules Work with AI Blog About Changelog
  • 01Why Runable?
  • 02Docs
  • 03Modules
  • 04Work with AI
  • 05Blog
  • 06About
  • 07Changelog
Vue without a fixed server runtime.
All modules

@runablejs/Pinia

Official module

Add Pinia 3 state management to Runable with automatic store imports, SSR isolation, and optional persistence powered by Unstorage.

Install with pnpm

Source code

@runablejs/pinia creates a fresh Pinia instance for every Runable application. Stores, Pinia helpers, and files exported from app/stores are available through auto-imports, with no application plugin to configure manually.

Installation

Install the Runable module and Pinia:

pnpm add @runablejs/pinia pinia

Then register the module in runable.config.ts:

import { defineConfig } from "runable";

export default defineConfig({
  modules: ["@runablejs/pinia"],
});

Create a store

Create app/stores/counter.ts. defineStore is auto-imported:

export const useCounterStore = defineStore("counter", {
  state: () => ({ count: 0 }),
  actions: {
    increment() {
      this.count++;
    },
  },
});

The exported store is auto-imported in components and composables:

<script setup lang="ts">
const counter = useCounterStore();
const { count } = storeToRefs(counter);
</script>

<template>
  <button type="button" @click="counter.increment()">
    Count: {{ count }}
  </button>
</template>

Options

OptionTypeDefaultDescription
storeDirsstring[]['{appDir}/stores']Directories containing stores to auto-import.
persistbooleanfalseEnable persistence for every store by default.
unstorageUnstorageOptionsBrowser local storageConfigure the persistence storage.

Scan additional store directories

Use storeDirs when stores live outside app/stores. Paths are relative to the Runable project root:

import { defineConfig } from "runable";

export default defineConfig({
  modules: ["@runablejs/pinia"],
  pinia: {
    storeDirs: ["app/stores", "features/account/stores"],
  },
});

Setting storeDirs replaces the default list.

Persist a store

Persistence uses Unstorage. Enable it on an individual store:

export const usePreferencesStore = defineStore("preferences", {
  state: () => ({ theme: "light" }),
  persist: true,
});

Use a custom key when the store identifier should not be used for storage:

export const usePreferencesStore = defineStore("preferences", {
  state: () => ({ theme: "light" }),
  persist: {
    key: "user-preferences",
  },
});

Hydration is asynchronous. Await $persistReady before reading restored state in code that must wait for persistence:

const preferences = usePreferencesStore();

await preferences.$persistReady;
await preferences.$persist();
await preferences.$hydrate();

Configure persistence globally

Enable persistence for every store and choose between local and session storage from runable.config.ts:

export default defineConfig({
  modules: ["@runablejs/pinia"],
  pinia: {
    persist: true,
    unstorage: {
      namespace: "my-app:pinia:",
      windowKey: "sessionStorage",
    },
  },
});

Set persist: false on a store to opt out when global persistence is enabled. You can also provide a custom Unstorage driver through pinia.unstorage.driver.

During SSR, each request receives an isolated Pinia instance and an isolated in-memory persistence store. Browser storage is only used on the client.

Category
State Management
Compatibility
Runable 1.x · Pinia 3 · Vue 3.5+
Maintainer
Runable Team

Resources

DocumentationView on npmLearn more
Runable

The Vue framework that brings productive conventions to any backend.

Product

  • Why Runable
  • Documentation
  • Installation
  • Integrations

Project

  • About
  • Blog
  • Changelog
  • Sponsor

Community

  • GitHub
  • Issues
  • Discussions
  • Bluesky

© 2026 Runable. Released under the MIT License.

Open source Built with Vue and Runable