A modern Vue.js application demonstrating how to use SQLite in the browser through WebAssembly. This project showcases building offline-capable applications with a real SQL database running entirely in the browser.
- 🗄️ Full SQLite database in the browser via WebAssembly
- 📁 CSV Import - Import CSV files directly into SQLite tables
- 🚀 Vue 3.5 with Composition API
- ⚡️ Vite 5 for development
- 🎯 TypeScript 5.6 for type safety
- 💾 Persistent storage using Origin Private File System (OPFS)
- 🧵 Background processing with Web Workers
- 🎨 TailwindCSS 3 for styling
- SQLite Wasm: SQLite compiled to WebAssembly for browser execution
- Web Workers: Background thread for database operations
- OPFS: Persistent storage for database files
- @sqlite.org/sqlite-wasm: Official SQLite WebAssembly package
- Node.js (version 20.x or higher)
- Modern browser with WebAssembly and OPFS support
- npm (comes with Node.js)
-
Clone the repository:
git clone https://github.com/your-username/vue-sqlite-playground.git cd vue-sqlite-playground -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and visit
http://localhost:5173
- Create and manage SQLite databases in the browser
- Import CSV files into SQLite tables with transaction support
- Execute SQL queries directly in the UI
- View query results in real-time
- Persistent storage across browser sessions
- Example CRUD operations
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Lint and fix filesnpm run type-check- Check TypeScript types
This application requires a modern browser with support for:
- WebAssembly
- Web Workers
- Origin Private File System (OPFS)
- SharedArrayBuffer
The SQLite database is configured with a sample table structure:
CREATE TABLE IF NOT EXISTS test_table (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);The application includes a powerful CSV import feature that allows you to import data from CSV files directly into SQLite tables:
Features:
- Browser-based CSV parsing (no server required)
- Transaction-wrapped imports for data integrity
- Automatic rollback on errors
- Real-time progress and error reporting
- Support for custom table names and column mappings
How it works:
- Navigate to the CSV Import page
- Specify your table name and column names (comma-separated)
- Select a CSV file from your computer
- The file is parsed in JavaScript and inserted using parameterized SQL queries
- All inserts are wrapped in a transaction for performance and consistency
- View imported data immediately in the table preview
Example CSV format:
id,name
1,Alice Johnson
2,Bob Smith
3,Charlie Davis
Important Notes:
- CSV files must have a header row
- Column names must match the order in your CSV file
- SQLite CLI dot commands (
.import,.mode csv) don't work in the browser - this JavaScript-based approach provides equivalent functionality - For complex CSVs with quoted fields or special characters, consider using a library like Papa Parse
Download Sample CSV:
A sample users.csv file is included in the public/ directory for testing.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
For a detailed explanation of how this works, check out our blog post about implementing SQLite in Vue 3 applications.
