A React Hook wrapper around @Capacitor-community/sqlite, providing a simple interface for using SQLite databases in Capacitor-based mobile apps. Version 3.2.1 is the latest stable release, with active development and occasional minor updates. It simplifies database initialization, queries, and transactions inside React components using hooks like useSQLite. Key differentiators: fully typed with TypeScript, follows React best practices, and integrates seamlessly with Capacitor's lifecycle. Requires React 18+ and the Capacitor SQLite plugin.
npm install react-sqlite-hookNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to wrap your app in SQLiteProvider and use useSQLite hook to create a table, insert a row, and query.
Update React to 18+ or stay on react-sqlite-hook 2.x if you cannot upgrade React.
Replace default import with named imports like `import { useSQLite } from 'react-sqlite-hook'`.Replace `const db = await open()` with `const db = await openDatabase('mydb')`.Ensure `@capacitor-community/sqlite` is added to your Capacitor project and synced to native builds.
Use a ref to track initialization: `const initialized = useRef(false);`.
Run `npm install react-sqlite-hook` and ensure you are importing from the correct package name.
Wrap the component tree in <SQLiteProvider>.
Run `npm install @capacitor-community/sqlite` then `npx cap sync`.
Upgrade to React 18 or downgrade react-sqlite-hook to v2.