Skip to content

Commit ca5158f

Browse files
committed
docs: Update README.md to enhance clarity and structure, including feature list and usage examples
1 parent c93cb74 commit ca5158f

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

sqlite-wasm/README.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22

33
SQLite WASM conveniently wrapped as an ES Module. It includes the [sqlite-sync](https://github.com/sqliteai/sqlite-sync) and [sqlite-vector](https://github.com/sqliteai/sqlite-vector) extensions that are automatically loaded at runtime. TypeScript types are from the [official sqlite-wasm repository](https://github.com/sqlite/sqlite-wasm).
44

5+
## Features
6+
7+
- 🚀 SQLite WASM wrapped as an ES Module
8+
- 🔄 Includes sqlite-sync and sqlite-vector extensions
9+
- 📝 Full TypeScript support
10+
- 💾 OPFS (Origin Private File System) support for persistent storage
11+
- ⚡ Worker thread support for better performance
12+
513
## Installation
614

715
```bash
816
npm install @sqliteai/sqlite-wasm
917
```
1018

11-
## Vite Usage Example
19+
## Vite Configuration
1220

13-
If you are using [vite](https://vitejs.dev/), you need to add the following
14-
config option in `vite.config.js`:
21+
If you are using [Vite](https://vitejs.dev/), you need to add the following configuration options to your `vite.config.js`:
1522

1623
```js
1724
import { defineConfig } from 'vite';
@@ -29,20 +36,19 @@ export default defineConfig({
2936
});
3037
```
3138

32-
Check out the [sport-tracker-app example](https://github.com/sqliteai/sqlite-sync/tree/main/examples/sport-tracker-app) that shows this in action while using SQLite WASM in a worker thread.
39+
💡 **Example**: Check out the [sport-tracker-app example](https://github.com/sqliteai/sqlite-sync/tree/main/examples/sport-tracker-app) to see SQLite WASM in action with a worker thread implementation.
3340

3441
## Usage
3542

36-
There are three ways to use SQLite Wasm:
43+
There are three ways to use SQLite WASM:
3744

38-
- [in the main thread with a wrapped worker](#in-a-wrapped-worker-with-opfs-if-available)
39-
- [in a worker](#in-a-worker-with-opfs-if-available)
40-
- [in the main thread](#in-the-main-thread-without-opfs) (⚠️ sqlite-sync does not work in the main thread)
45+
1. **[Wrapped Worker](#wrapped-worker-with-opfs-support)** - Uses a wrapped worker (recommended)
46+
2. **[Direct Worker](#direct-worker-with-opfs-support)** - Uses a direct worker implementation
47+
3. **[Main Thread](#main-thread-without-opfs)** - Runs in the main thread ⚠️ *sqlite-sync does not work in the main thread*
4148

42-
Only the worker versions allow you to use the origin private file system (OPFS)
43-
storage back-end.
49+
> 💡 **Note**: Only the worker versions support the Origin Private File System (OPFS) storage backend for persistent data storage.
4450
45-
### In a wrapped worker (with OPFS if available):
51+
### Wrapped Worker (with OPFS Support)
4652

4753
> [!Warning]
4854
>
@@ -93,10 +99,9 @@ const initializeSQLite = async () => {
9399
initializeSQLite();
94100
```
95101

96-
The `promiser` object above implements the
97-
[Worker1 API](https://sqlite.org/wasm/doc/trunk/api-worker1.md#worker1-methods).
102+
> 📚 **API Reference**: The `promiser` object implements the [Worker1 API](https://sqlite.org/wasm/doc/trunk/api-worker1.md#worker1-methods).
98103
99-
### In a worker (with OPFS if available):
104+
### Direct Worker (with OPFS Support)
100105

101106
> [!Warning]
102107
>
@@ -106,13 +111,13 @@ The `promiser` object above implements the
106111
>
107112
> `Cross-Origin-Embedder-Policy: require-corp`
108113
114+
**Main thread (`main.js`):**
109115
```js
110-
// In `main.js`.
111116
const worker = new Worker('worker.js', { type: 'module' });
112117
```
113118

119+
**Worker thread (`worker.js`):**
114120
```js
115-
// In `worker.js`.
116121
import sqlite3InitModule from '@sqliteai/sqlite-wasm';
117122

118123
const log = console.log;
@@ -146,10 +151,9 @@ const initializeSQLite = async () => {
146151
initializeSQLite();
147152
```
148153

149-
The `db` object above implements the
150-
[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
154+
> 📚 **API Reference**: The `db` object implements the [Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
151155
152-
### In the main thread (without OPFS):
156+
### Main Thread (without OPFS)
153157

154158
```js
155159
import sqlite3InitModule from '@sqliteai/sqlite-wasm';
@@ -180,15 +184,19 @@ const initializeSQLite = async () => {
180184
initializeSQLite();
181185
```
182186

183-
The `db` object above implements the
184-
[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
187+
> 📚 **API Reference**: The `db` object implements the [Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
188+
189+
## Resources
190+
191+
- 📖 [SQLite WASM Documentation](https://sqlite.org/wasm)
192+
- 🔧 [Worker1 API Reference](https://sqlite.org/wasm/doc/trunk/api-worker1.md)
193+
- 🛠️ [Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md)
194+
- 📦 [Package on NPM](https://www.npmjs.com/package/@sqliteai/sqlite-wasm)
185195

186196
## License
187197

188-
Apache 2.0.
198+
**Apache 2.0**
189199

190200
## Acknowledgements
191201

192-
This project is based on [SQLite Wasm](https://sqlite.org/wasm), which it
193-
conveniently wraps as an ES Module and publishes to npm as
194-
[`@sqliteai/sqlite-wasm`](https://www.npmjs.com/package/@sqliteai/sqlite-wasm).
202+
This project is based on [SQLite WASM](https://sqlite.org/wasm), which is conveniently wrapped as an ES Module and published to npm as [`@sqliteai/sqlite-wasm`](https://www.npmjs.com/package/@sqliteai/sqlite-wasm).

0 commit comments

Comments
 (0)