@supabase/lite 0.0.1 โ 0.2.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +311 -0
- package/STATUS.md +844 -0
- package/UPGRADE.md +221 -0
- package/dist/cli/index.js +330 -29421
- package/dist/cli/lib.js +49 -6273
- package/dist/db/browser/index.js +19 -15485
- package/dist/db/bun/index.js +19 -15473
- package/dist/db/fallback.js +18 -15369
- package/dist/db/node/index.js +19 -15466
- package/dist/db/postgres/PostgresConnection.js +18 -365
- package/dist/db/postgres/pglite/PgliteConnection.js +20 -642
- package/dist/db/workerd/index.js +18 -15591
- package/dist/index.js +258 -32242
- package/dist/vite/index.js +3 -1910
- package/package.json +8 -9
- package/dist/Connection-BJclIu8v.d.ts +0 -529
- package/dist/Connection-BsiQMo4A.d.ts +0 -562
- package/dist/db/postgres/BasePostgresConnection-COHRCvc-.d.ts +0 -24
- package/dist/db/postgres/BasePostgresConnection-Di94o0ON.d.ts +0 -24
- package/dist/db/postgres/index.js +0 -802
- package/dist/db/sqlite/index.js +0 -14724
- package/dist/index-4cbfQyFv.d.ts +0 -763
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
> [!WARNING]
|
|
2
|
+
> **๐ง Alpha.** Supalite is pre-1.0 and under active development. APIs, config shape, and on-disk format may change. Not for production use yet. See [Feature Overview](#feature-overview) for current state.
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
# Supabase Lite
|
|
10
|
+
|
|
11
|
+
Lightweight TypeScript-native Supabase implementation. SQLite as the primary database, with PGlite and Postgres support. Ships a PostgREST-compatible REST API and a GoTrue-compatible Auth API, so `@supabase/supabase-js` works as-is.
|
|
12
|
+
|
|
13
|
+
Supalite targets AI builders who want quick, cheap prototypes today with a clear path to upgrade later. It supplements Supabase rather than replacing it. The project stays lightweight by implementing only what fits on top of non-UDF SQLite: roughly 60% of the most-used Supabase features, focused on the subset most useful for fast iteration.
|
|
14
|
+
|
|
15
|
+
**Scope:** Both declarative schema (`supabase/schemas/*.sql`) and imperative Postgres migrations (`supabase/migrations/*.sql`, Supabase-CLI compatible) are supported. See [Migrations](#migrations). Advanced Postgres-specific column types (ranges, arrays of composites, and similar) are not available.
|
|
16
|
+
|
|
17
|
+
Validated against the upstream PostgREST and GoTrue test suites: 1,803 tests passing.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Feature overview
|
|
22
|
+
|
|
23
|
+
Compatibility is measured from the `@supabase/supabase-js` surface. The goal is that code written against Supabase keeps working when pointed at @supabase/lite. Direct database access (raw SQL clients, Postgres wire protocol, `psql`) is **not** a target; everything below is scoped to what supabase-js exercises.
|
|
24
|
+
|
|
25
|
+
| Service | Status | Notes |
|
|
26
|
+
|-------------------------|--------|--------------------------------------------------------------------|
|
|
27
|
+
| [Databases](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#database-support) | โ
| `bun:sqlite`, `node:sqlite`, sqlite-wasm, Cloudflare D1 + DO, PGlite, PostgreSQL |
|
|
28
|
+
| [Data API (PostgREST)](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#database-api-postgrest-compatible) | โ
| 47/74 supabase-js methods on SQLite: `from`, `select`, `insert`, `update`, `delete`, `upsert`, `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `notIn`, `is`, `isDistinct`, `like`, `ilike`, `likeAllOf`, `likeAnyOf`, `ilikeAllOf`, `ilikeAnyOf`, `match`, `or`, `not`, `filter`, `order`, `limit`, `range`, `single`, `maybeSingle`, `csv`, `abortSignal`, `setHeader`, `throwOnError`, `maxAffected`, `returns`, `overrideTypes`, plus full resource embedding (FK joins, `!inner`, spreads, nested, aggregates). Partial: `contains`, `containedBy`, `overlaps`. `rpc` not supported on SQLite. 72/74 on Postgres. |
|
|
29
|
+
| [Auth API (GoTrue)](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#auth-api-gotrue-compatible) | โ
| 21/63 supabase-js methods (11 backend + 10 client-side helpers): `signUp`, `signInWithPassword`, `signInWithOtp`, `verifyOtp`, `refreshSession`, `signOut`, `getUser`, `updateUser`, `resetPasswordForEmail`, `resend`, `reauthenticate`. OAuth, anonymous, identity linking, admin API, and MFA planned. |
|
|
30
|
+
| [Storage API](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#storage-api-compatible) | ๐งช | 20/20 supabase-js methods: `upload`, `download`, `list`, `remove`, `move`, `copy`, `info`, `exists`, `update`, `getPublicUrl`, `createSignedUrl`, `createSignedUrls`, `createSignedUploadUrl`, `uploadToSignedUrl`, `listBuckets`, `getBucket`, `createBucket`, `updateBucket`, `deleteBucket`, `emptyBucket`. Role-based access + RLS pending. <br />โ ๏ธ Gated behind `EXPERIMENTAL_STORAGE`. |
|
|
31
|
+
| Realtime | ๐ | Coming soon |
|
|
32
|
+
| Edge Functions | ๐ | Coming soon |
|
|
33
|
+
| Cloud Hosting | ๐ | Coming soon |
|
|
34
|
+
| [CLI](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#cli) | โ
| Upstream `supabase` CLI parity for: `init`, `start`, `db diff`, `db query`. Aligned to v2.98.2 command shape. |
|
|
35
|
+
| [Upgrade to Supabase](https://github.com/supabase-community/lite/blob/HEAD/UPGRADE.md) | ๐งช | `lite upgrade` migrates a project to hosted or local Supabase: schema + user-table data + auth sessions (signing-key import). Storage/realtime migration pending. SQLite shim health audit via `--dry-run`. |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @supabase/lite # global, exposes `lite` CLI
|
|
43
|
+
# or per-project: npm install @supabase/lite (run via `npx @supabase/lite <cmd>`)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
lite init # scaffold supabase/ directory
|
|
50
|
+
lite dev # start server with schema hot-reload
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The API is now running at `http://localhost:54321`. Point `@supabase/supabase-js` at it:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { createClient } from "@supabase/supabase-js";
|
|
57
|
+
|
|
58
|
+
const supabase = createClient("http://localhost:54321", "any-string-works-for-now");
|
|
59
|
+
const { data } = await supabase.from("todos").select("*");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
> No anon key is required yet. Pass any non-empty string as the second argument.
|
|
63
|
+
|
|
64
|
+
Edit `supabase/schemas/schema.sql` and the dev server re-applies the schema automatically.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## CLI
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
lite <command> [options]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Local commands
|
|
75
|
+
|
|
76
|
+
| Command | Description |
|
|
77
|
+
|------------------|---------------------------------------------------------------|
|
|
78
|
+
| `init` | Scaffold `supabase/` (config, schema, seed, data dir) |
|
|
79
|
+
| `dev` | Start server + watch `schemas/*.sql`, auto-apply on change |
|
|
80
|
+
| `start` | Start server (no watch, no auto-migrate) |
|
|
81
|
+
| `db schema` | Print current DB schema; `--diff` compares vs `schemas/*.sql` |
|
|
82
|
+
| `migration diff` | Generate/apply migrations from schema diff |
|
|
83
|
+
| `repl` | Interactive REPL with `app`, `client`, `conn` in scope |
|
|
84
|
+
| `db query` | Run a SQL statement against the local DB |
|
|
85
|
+
| `debug` | Show runtime/config info |
|
|
86
|
+
|
|
87
|
+
Common flags:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
lite init --pglite # use PGlite instead of SQLite
|
|
91
|
+
lite dev --recreate # wipe DB and reapply schema on start
|
|
92
|
+
lite db schema --diff # diff current DB vs schemas/*.sql
|
|
93
|
+
lite db schema --sql # print raw CREATE statements
|
|
94
|
+
lite migration diff # preview migration plan
|
|
95
|
+
lite migration diff --execute --force # apply, overriding data-loss warnings
|
|
96
|
+
lite db query "select count(*) from todos"
|
|
97
|
+
lite upgrade --dry-run # rehearsal plus SQLite shim audit
|
|
98
|
+
lite upgrade --dry-run --json # machine-readable shim audit output
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Upgrade targets:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
lite upgrade --target hosted # default: create/migrate to hosted Supabase
|
|
105
|
+
lite upgrade --target local # initialize/migrate local Supabase in the current directory
|
|
106
|
+
lite upgrade --target local --local-dir ../my-local-supabase
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
See [UPGRADE.md](https://github.com/supabase-community/lite/blob/HEAD/UPGRADE.md) for upgrade behavior, target differences, session migration, known gaps, and test strategy.
|
|
110
|
+
|
|
111
|
+
### Telemetry
|
|
112
|
+
|
|
113
|
+
The `lite` CLI sends anonymous usage telemetry to help prioritize fixes and features. No personally identifiable information is collected: no file paths, project names, DB URLs, env values, hostnames, IPs, or stack traces. Only the command name, CLI flag presence (boolean, never values), runtime (node/bun/deno), node version, platform/arch, CI/agent/container detection, DB driver (`sqlite`/`sqlite-postgres`/`pglite`/`postgres`), DB location (`file`/`memory`/`local`/`remote`), and DB size bucket.
|
|
114
|
+
|
|
115
|
+
Opt out with any of:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
lite --no-telemetry <cmd>
|
|
119
|
+
LITE_TELEMETRY=0 lite <cmd>
|
|
120
|
+
DO_NOT_TRACK=1 lite <cmd> # https://consoledonottrack.com
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Vite plugin
|
|
124
|
+
|
|
125
|
+
If your frontend uses Vite, skip the separate CLI + proxy setup. The
|
|
126
|
+
`@supabase/lite/vite` plugin runs the supalite backend inline inside the Vite dev
|
|
127
|
+
server, so one process serves both your app and the API.
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// vite.config.ts
|
|
131
|
+
import { defineConfig } from "vite";
|
|
132
|
+
import { supalite } from "@supabase/lite/vite";
|
|
133
|
+
|
|
134
|
+
export default defineConfig({
|
|
135
|
+
plugins: [supalite()],
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Then from your frontend:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { createClient } from "@supabase/supabase-js";
|
|
143
|
+
|
|
144
|
+
const client = createClient(
|
|
145
|
+
import.meta.env.VITE_SUPABASE_URL,
|
|
146
|
+
import.meta.env.VITE_SUPABASE_ANON_KEY,
|
|
147
|
+
);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The plugin auto-resolves `./supabase/config.toml`, applies the schema on boot,
|
|
151
|
+
watches `schemas/*.sql` for hot-reload, and mounts `/auth/v1`, `/rest/v1`, and
|
|
152
|
+
`/_system` on the Vite server. Only active during `vite` / `vite dev`.
|
|
153
|
+
|
|
154
|
+
See [`examples/todo`](https://github.com/supabase-community/lite/tree/HEAD/examples/todo) for a full Vite + React + Tailwind + RLS example, or [`examples/next-todo`](https://github.com/supabase-community/lite/tree/HEAD/examples/next-todo) for the same pattern using Next.js App Router catch-all route handlers.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Project layout
|
|
159
|
+
|
|
160
|
+
`lite init` creates a Supabase-compatible directory layout:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
supabase/
|
|
164
|
+
โโโ config.toml # API port, auth settings, DB path, etc.
|
|
165
|
+
โโโ schemas/
|
|
166
|
+
โ โโโ schema.sql # Postgres DDL, auto-translated to SQLite
|
|
167
|
+
โโโ seed.sql # Seed data, applied after migrations
|
|
168
|
+
โโโ .temp/
|
|
169
|
+
โโโ data.db # SQLite database (git-ignored)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`config.toml` follows the [Supabase CLI config format](https://supabase.com/docs/guides/local-development/cli/config). Minimal example:
|
|
173
|
+
|
|
174
|
+
```toml
|
|
175
|
+
[api]
|
|
176
|
+
port = 54321
|
|
177
|
+
max_rows = 1000
|
|
178
|
+
|
|
179
|
+
[db]
|
|
180
|
+
driver = "sqlite-postgres" # or "sqlite" | "pglite" | "postgres"
|
|
181
|
+
url = "file:./supabase/.temp/data.db"
|
|
182
|
+
|
|
183
|
+
[db.migrations]
|
|
184
|
+
schema_paths = ["./schemas/schema.sql"]
|
|
185
|
+
|
|
186
|
+
[db.seed]
|
|
187
|
+
sql_paths = ["./seed.sql"]
|
|
188
|
+
|
|
189
|
+
[auth]
|
|
190
|
+
enabled = true
|
|
191
|
+
jwt_secret = "dev-secret-change-me"
|
|
192
|
+
jwt_expiry = 3600
|
|
193
|
+
enable_signup = true
|
|
194
|
+
|
|
195
|
+
[auth.email]
|
|
196
|
+
enable_confirmations = false
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
> **`auth.jwt_secret`**: if omitted, auth falls back to the insecure placeholder `"unsafe-secret-change-me"` so local dev doesn't break. Always set your own for anything beyond throwaway local use.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Writing schemas
|
|
204
|
+
|
|
205
|
+
Write **Postgres DDL** in `supabase/schemas/*.sql`. When the DB driver is SQLite, DDL is translated on the fly (`SERIAL` โ `INTEGER PRIMARY KEY AUTOINCREMENT`, `NOW()` โ `datetime('now')`, `JSONB` โ `TEXT` with a `json_valid()` check, and so on). Postgres-only features that don't translate (ranges, `LATERAL`, table inheritance) throw a descriptive error.
|
|
206
|
+
|
|
207
|
+
RLS works across all backends: on SQLite, policies are extracted from DDL and enforced at the application layer by rewriting the query AST; on PGlite/Postgres, native RLS is used. `auth.uid()`, `auth.jwt()`, and roles (`anon`, `authenticated`) resolve from the JWT.
|
|
208
|
+
|
|
209
|
+
Full translation reference: [STATUS.md#postgres-to-sqlite-translation](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#postgres-to-sqlite-translation) and [`app/POSTGRES-SQLITE-COMPAT.md`](https://github.com/supabase-community/lite/blob/HEAD/app/POSTGRES-SQLITE-COMPAT.md).
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Migrations
|
|
214
|
+
|
|
215
|
+
Imperative Postgres migrations live in `supabase/migrations/*.sql` (Supabase-CLI compatible โ same filename format `<14-digit-ts>_<name>.sql`, same history table `supabase_migrations.schema_migrations`). On `sqlite-postgres`, `pglite`, and `postgres` drivers, write raw Postgres DDL โ the runtime translates it on the fly. On the bare `sqlite` driver, write sqlite DDL in `supabase/sqlite-migrations/*.sql` instead.
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
lite migration new add_users # create supabase/migrations/<ts>_add_users.sql
|
|
219
|
+
# ... edit the file ...
|
|
220
|
+
lite migration up # apply pending migrations
|
|
221
|
+
lite migration list # show applied vs pending
|
|
222
|
+
lite db diff -f tweak # diff schemas/ against applied migrations, emit a new pg-DDL migration
|
|
223
|
+
lite db reset # drop everything, replay migrations, run seed
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Migrations and declarative schemas coexist: `lite dev` and the Vite plugin apply pending migrations on boot, then run the declarative diff. RLS policies authored in migration files are picked up at request time.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Using `@supabase/supabase-js`
|
|
231
|
+
|
|
232
|
+
Two ways to get a client:
|
|
233
|
+
|
|
234
|
+
### Over HTTP
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import { createClient } from "@supabase/supabase-js";
|
|
238
|
+
|
|
239
|
+
const client = createClient("http://localhost:54321", "<anon-key>");
|
|
240
|
+
|
|
241
|
+
// database
|
|
242
|
+
const { data } = await client.from("todos").select("*");
|
|
243
|
+
|
|
244
|
+
// auth
|
|
245
|
+
await client.auth.signUp({ email: "a@b.com", password: "secret123" });
|
|
246
|
+
const { data: session } = await client.auth.signInWithPassword({
|
|
247
|
+
email: "a@b.com",
|
|
248
|
+
password: "secret123",
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### In-process (no network)
|
|
253
|
+
|
|
254
|
+
When you embed the app:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
const client = app.getClient();
|
|
258
|
+
const { data } = await client.from("todos").select("*");
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Queries route through `app.fetch` internally. Same API, no HTTP round trip.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Embedded / programmatic
|
|
266
|
+
|
|
267
|
+
Embed @supabase/lite in any Web-API-compliant runtime (Bun, Node, browser, and edge runtimes).
|
|
268
|
+
|
|
269
|
+
### Bun / Node
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import { App } from "@supabase/lite";
|
|
273
|
+
import { createConnection } from "@supabase/lite/sqlite"; // picks driver per runtime
|
|
274
|
+
|
|
275
|
+
const connection = await createConnection({ url: "file:./data.db" });
|
|
276
|
+
const app = new App({ connection, auth: { enabled: true } });
|
|
277
|
+
|
|
278
|
+
// optionally apply schema on boot
|
|
279
|
+
const schema = await Bun.file("./schema.sql").text();
|
|
280
|
+
await app.connection.createMigrator(schema).migrate();
|
|
281
|
+
|
|
282
|
+
export default app; // app.fetch handles requests
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Supported databases
|
|
286
|
+
|
|
287
|
+
| Runtime/DB | Driver |
|
|
288
|
+
|--------------|----------------------------------|
|
|
289
|
+
| Bun | `bun:sqlite` (auto) |
|
|
290
|
+
| Node.js โฅ 22 | `node:sqlite` (auto) |
|
|
291
|
+
| Browser | `@sqlite.org/sqlite-wasm` (auto) |
|
|
292
|
+
| Workerd | `@supabase/lite/workerd` |
|
|
293
|
+
| PGlite | `@supabase/lite/pglite` |
|
|
294
|
+
| Postgres | `@supabase/lite/postgres` |
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## REPL
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
lite repl
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Gives you an interactive session with `app`, `client` (supabase-js), `conn`, and `db` in scope. Built-in commands: `.tables`, `.table <name>`, `.indexes`, `.config [path]`.
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
> await client.from("todos").select("*")
|
|
309
|
+
> .tables
|
|
310
|
+
> .table todos
|
|
311
|
+
```
|