Registry / storage / vue-data-storage-sqlite-hook

vue-data-storage-sqlite-hook

JSON →
library3.0.0jsnpmunverified

Vue 3 composable hook for capacitor-data-storage-sqlite plugin, providing reactive SQLite storage in Capacitor apps. Version 3.0.0 targets Capacitor 5 and Vue 3 composition API. The hook exposes methods like openStore, closeStore, clear, setItem, getItem, etc. It requires capacitor-data-storage-sqlite as a runtime dependency (not bundled). Low maintenance frequency (last update 2023). Alternative to raw plugin calls with Vue reactivity integration.

npm install vue-data-storage-sqlite-hook
INSTALL
IMPORT
SIG · VUE-DATA-STORAGE-S
V
vue-data-storage-sqlite-hook
storagejavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useStorageSQLite
import { useStorageSQLite } from 'vue-data-storage-sqlite-hook/dist';
import { useStorageSQLite } from 'vue-data-storage-sqlite-hook';
Must import from '/dist' subpath. The package does not expose a default export; always use named import.
StorageSQLiteHook
import type { StorageSQLiteHook } from 'vue-data-storage-sqlite-hook/dist';
import { StorageSQLiteHook } from 'vue-data-storage-sqlite-hook';
TypeScript type for the hook return value. Use type-only import if not needed at runtime. Not available from root package.
useStorageSQLite
const { useStorageSQLite } = await import('vue-data-storage-sqlite-hook/dist');
const useStorageSQLite = require('vue-data-storage-sqlite-hook');
The package is ESM-only; CommonJS require will fail. Use dynamic import for CJS environments.

Shows how to install, import, and use useStorageSQLite in a Vue 3 component with Capacitor. Includes openStore, setItem, getItem, closeStore.

import { defineComponent, getCurrentInstance, onMounted } from 'vue'; import { useStorageSQLite } from 'vue-data-storage-sqlite-hook/dist'; export default defineComponent({ name: 'App', setup() { const app = getCurrentInstance(); onMounted(async () => { if (app) { app.appContext.config.globalProperties.$storageSqlite = useStorageSQLite(); } }); } }); // In child component: import { defineComponent, getCurrentInstance, onMounted } from 'vue'; import { Dialog } from '@capacitor/dialog'; export default defineComponent({ name: 'Example', setup() { const app = getCurrentInstance(); const storageSqlite = app?.appContext.config.globalProperties.$storageSqlite; const storeData = async () => { try { await storageSqlite.openStore({}); await storageSqlite.setItem('key', 'value'); const value = await storageSqlite.getItem('key'); console.log('Retrieved:', value); await storageSqlite.closeStore(); } catch (e) { console.error(e); } }; onMounted(storeData); } });
Debug
Known issues
gotchaImport path must include '/dist' suffix. Importing from 'vue-data-storage-sqlite-hook' directly will not resolve.
fix
Change import to 'vue-data-storage-sqlite-hook/dist'.
affects: >=3.0.0
breakingVersion 3.0.0 drops support for Capacitor 4 and Vue 2. Requires @capacitor/core ^5.0.0 and Vue 3.
fix
Upgrade to Capacitor 5 and Vue 3. For Capacitor 4/Vue 2, use version 1.x.
affects: >=3.0.0
gotchaThe hook uses 'getCurrentInstance()' which can be null if called outside setup. Always check for null before accessing.
fix
Add null check: const app = getCurrentInstance(); if (app) { ... }
affects: >=1.0.0
deprecatedAccessing globalProperties for hook injection is a workaround; consider using provide/inject or Pinia stores for state management.
fix
Use Vue's provide/inject pattern: in App.vue provide('storageSqlite', useStorageSQLite()); in child inject('storageSqlite').
affects: >=3.0.0
gotchaThe hook relies on capacitor-data-storage-sqlite plugin. If the native plugin is not installed or configured, all calls will throw.
fix
Ensure capacitor-data-storage-sqlite is installed and the capacitor sync/run commands were executed.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'vue-data-storage-sqlite-hook' or its corresponding type declarations.
Import path missing '/dist' subpath.
fix
Import from 'vue-data-storage-sqlite-hook/dist'.
Uncaught TypeError: Cannot read properties of null (reading 'appContext')
getCurrentInstance() returned null because called outside Vue setup context.
fix
Ensure getCurrentInstance() is called inside setup() or check for null before using.
Capacitor is not defined
Capacitor runtime not loaded. Usually happens if running in browser without capacitor or if @capacitor/core is missing.
fix
Install @capacitor/core: npm install @capacitor/core; and ensure the app runs in a native environment or use capacitor serve.
TypeError: (intermediate value).openStore is not a function
The hook was not initialized properly (e.g., $storageSqlite might be undefined).
fix
Ensure the hook is set on app.config.globalProperties.$storageSqlite before any component tries to use it.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
capacitor-data-storage-sqliterequiredPeer dependency providing the underlying SQLite storage plugin for Capacitor
@capacitor/corerequiredPeer dependency required by Capacitor plugins (Capacitor 5)
vuerequiredPeer dependency for Vue 3 composable API
Agent activity
30 hits · last 30 days
node
24
Meta
2
Resources
vue-data-storage-sqlite-hook — npm install vue-data-storage-sqlite-hook · libregistry