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
feat: add AuthPlugin to studio kernel factory and document MSW/mock mode
- Add AuthPlugin to apps/studio createKernel.ts for default auth in MSW mode
- Add @objectstack/plugin-auth dependency to studio package.json
- Update authentication.mdx: HTTP server is optional, add MSW/Mock Mode section
with minimal config example, mock fallback endpoints table, and studio usage
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy file name to clipboardExpand all lines: content/docs/guides/authentication.mdx
+66-1Lines changed: 66 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ Complete guide to implementing authentication in ObjectStack applications using
18
18
7.[Client Integration](#client-integration)
19
19
8.[API Reference](#api-reference)
20
20
9.[Best Practices](#best-practices)
21
+
10.[MSW/Mock Mode](#mswmock-mode)
21
22
22
23
---
23
24
@@ -89,7 +90,7 @@ import { HonoServerPlugin } from '@objectstack/plugin-hono-server';
89
90
90
91
const kernel =newObjectKernel({
91
92
plugins: [
92
-
// HTTP server (required for auth routes)
93
+
// HTTP server (optional — auth works without it in MSW/mock mode)
93
94
newHonoServerPlugin({
94
95
port: 3000,
95
96
}),
@@ -107,6 +108,10 @@ await kernel.start();
107
108
108
109
That's it! Your authentication endpoints are now available at `/api/v1/auth/*`.
109
110
111
+
> **MSW/Mock Mode:** AuthPlugin does **not** require an HTTP server. When HonoServerPlugin
112
+
> is absent, the plugin gracefully skips route registration and still registers the `auth`
113
+
> service. See [MSW/Mock Mode](#mswmock-mode) below for details.
114
+
110
115
### 3. ObjectQL Data Persistence
111
116
112
117
The plugin automatically uses ObjectQL for data persistence. No additional database configuration is required - it works with your existing ObjectQL setup.
@@ -586,6 +591,66 @@ better-auth internally uses model names like `user` and `session`. The ObjectQL
586
591
587
592
---
588
593
594
+
## MSW/Mock Mode
595
+
596
+
AuthPlugin is designed to work in **both** server and MSW/mock (browser-only) environments. This means you can develop and test authentication flows without running a real HTTP server.
597
+
598
+
### How It Works
599
+
600
+
-**Server mode** (HonoServerPlugin active): AuthPlugin registers HTTP routes at `/api/v1/auth/*` and forwards all requests to better-auth.
601
+
-**MSW/mock mode** (no HTTP server): AuthPlugin gracefully skips route registration but still registers the `auth` service. The `HttpDispatcher` provides mock fallback responses for core auth endpoints.
0 commit comments