Registry /
storage / vue-data-storage-sqlite-hook
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);
}
});
Errors
Common errors & fixes
Cannot find module 'vue-data-storage-sqlite-hook' or its corresponding type declarations.
Import path missing '/dist' subpath.
fixImport 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.
fixEnsure 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.
fixInstall @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).
fixEnsure the hook is set on app.config.globalProperties.$storageSqlite before any component tries to use it.
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