You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HotCRM can be deployed to **Vercel** as a serverless application using **Hono + Memory Driver** mode.
175
-
In this mode the full ObjectStack kernel runs server-side inside a Vercel Serverless Function — no external
176
-
database or Redis required. All data is stored in the function instance's memory.
174
+
HotCRM can be deployed to **Vercel** as a serverless application using **Hono + Turso Driver** mode.
175
+
In this mode the full ObjectStack kernel runs server-side inside a Vercel Serverless Function. When
176
+
`TURSO_DATABASE_URL` is set, data persists in a Turso cloud database across cold starts. Without it,
177
+
the driver falls back to `:memory:` (ephemeral SQLite, same behaviour as the old InMemoryDriver).
177
178
178
179
### How It Works
179
180
180
181
1. A catch-all Vercel Serverless Function (`api/[[...route]].ts`) bootstraps the ObjectStack kernel on first request.
181
-
2.`@objectstack/driver-memory` provides an in-memory data store — zero external infrastructure needed.
182
+
2.`@objectstack/driver-turso` provides a persistent Turso/libSQL data store. When `TURSO_DATABASE_URL` is set, data persists across cold starts; otherwise falls back to `:memory:`.
182
183
3.`HonoHttpServer` from `@objectstack/plugin-hono-server` handles HTTP routing (without TCP listener).
183
184
4.`createRestApiPlugin()` auto-generates CRUD endpoints for all 65+ business objects.
184
185
5. The kernel instance is reused across warm invocations (Vercel Fluid Compute).
@@ -197,7 +198,7 @@ Vercel Serverless Function
197
198
│ ├── 6 Business Plugins │
198
199
│ ├── Console UI (/console/) │
199
200
│ ├── Studio UI (/_studio/) │
200
-
│ └── InMemoryDriver (data store) │
201
+
│ └── TursoDriver (Turso cloud / :memory:) │
201
202
│ ↓ │
202
203
│ Response │
203
204
└──────────────────────────────────────────┘
@@ -213,6 +214,8 @@ Vercel Serverless Function
213
214
| Variable | Required | Default | Description |
214
215
|----------|----------|---------|-------------|
215
216
|`AUTH_SECRET`|**Yes** (production) | Dev fallback | Secret key used by the Auth Plugin (`@objectstack/plugin-auth`) for signing sessions and tokens. In production, set a strong random value (e.g. `openssl rand -base64 32`). A development fallback is used when not set. |
217
+
|`TURSO_DATABASE_URL`| No (recommended for prod) |`:memory:`| Turso database URL (e.g. `libsql://my-db-orgname.turso.io`). When set, data persists across cold starts. |
218
+
|`TURSO_AUTH_TOKEN`| When using remote URL | — | JWT auth token for the Turso database. Required when `TURSO_DATABASE_URL` points to a remote Turso cloud database. |
216
219
217
220
### Quick Start
218
221
@@ -289,7 +292,7 @@ Build pipeline:
289
292
|`buildCommand`|`bash scripts/build-vercel.sh`| Runs the Vercel build script that builds core, patches console plugin, then compiles all business plugins |
290
293
|`functions.memory`|`1024` MB | Memory allocated to the serverless function |
291
294
|`functions.maxDuration`|`60` s | Maximum execution time per request (Pro plan) |
292
-
|`functions.includeFiles`|`{packages/*/dist,node_modules/@object-ui/console/dist,node_modules/@objectstack/plugin-auth/dist,node_modules/@objectstack/studio/dist}/**`| Bundles business plugin dist/, Auth plugin, and Console/Studio SPA assets with the function |
295
+
|`functions.includeFiles`|`{packages/*/dist,node_modules/@object-ui/console/dist,node_modules/@objectstack/*/dist,node_modules/@libsql,node_modules/better-sqlite3,node_modules/@opentelemetry/api}/**`| Bundles business plugin dist/, all @objectstack packages (including Auth, Studio, TursoDriver), libSQL/better-sqlite3 native deps, and OpenTelemetry with the function |
293
296
|`rewrites`|`/(.*) → /api/[[...route]]`| Routes all requests to the catch-all handler |
294
297
295
298
### Architecture Details
@@ -309,14 +312,13 @@ a `HonoHttpServer`, registers it as the `http.server` service, and uses the `han
309
312
310
313
### Data Behavior
311
314
312
-
- Data lives in the function instance's process memory
313
-
- Warm invocations **share data** — records created in one request are visible in the next
314
-
- After ~5–15 minutes of inactivity, Vercel recycles the instance (cold start) and data resets
315
-
- For persistent data, see [Docker Deployment](#docker-deployment) or configure an external database
315
+
-**With `TURSO_DATABASE_URL`** (production recommended): data persists in a Turso cloud database across cold starts and instance recycling.
316
+
-**Without `TURSO_DATABASE_URL`** (local dev / demo): falls back to `:memory:` (ephemeral SQLite) — records persist only while the function instance is warm; data resets on cold start.
317
+
- Warm invocations **share data** — records created in one request are visible in the next.
316
318
317
319
### Limitations
318
320
319
-
-**Data is ephemeral** — records persist only while the function instance is warm; data resets on cold start.
321
+
-**Data is ephemeral without Turso** — without `TURSO_DATABASE_URL`, records persist only while the function instance is warm; data resets on cold start. Set `TURSO_DATABASE_URL` + `TURSO_AUTH_TOKEN` for persistent production data.
320
322
-**No authentication** — this mode does not enforce permissions or user sessions out of the box.
321
323
-**No WebSocket** — Vercel Serverless Functions do not support persistent connections.
322
324
-**Cold start latency** — the first request after idle may take 2–5 seconds for kernel bootstrap.
0 commit comments