better-auth-devtools 0.1.1-alpha.2 → 0.1.1-alpha.5

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.
Files changed (2) hide show
  1. package/README.md +104 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,110 @@
1
- # better-auth-devtools
1
+ # Better Auth DevTools
2
2
 
3
- An unofficial Better Auth devtool as a single installable package.
3
+ > [!WARNING]
4
+ > Unofficial, alpha, development-only tooling for Better Auth. Do not enable it in production.
4
5
 
5
- This package is currently in alpha and may introduce breaking changes between releases.
6
+ `better-auth-devtools` is a Better Auth devtool for local auth scenario testing. It gives you managed test users, instant session switching, session inspection, and a React panel for approved session-field edits.
6
7
 
7
- This package is unofficial and is not affiliated with, endorsed by, or maintained by the Better Auth team.
8
+ ## Installation
8
9
 
9
- Use subpath exports:
10
+ ```bash
11
+ pnpm add better-auth-devtools
12
+ ```
10
13
 
11
- - `better-auth-devtools/plugin`
12
- - `better-auth-devtools/react`
14
+ Use these subpath exports:
13
15
 
14
- See the root README for setup and demo usage.
16
+ ```ts
17
+ import { devtoolsPlugin, devtoolsClientPlugin } from "better-auth-devtools/plugin";
18
+ import { BetterAuthDevtools } from "better-auth-devtools/react";
19
+ ```
20
+
21
+ Required environment guard:
22
+
23
+ ```bash
24
+ DEV_AUTH_ENABLED=true
25
+ NODE_ENV=development
26
+ ```
27
+
28
+ ## AI Agent Prompt
29
+
30
+ ```text
31
+ Install and integrate better-auth-devtools as an unofficial development-only Better Auth utility. Use better-auth-devtools/plugin for the Better Auth server/client plugin setup and better-auth-devtools/react for the floating panel. Keep it disabled in production, require DEV_AUTH_ENABLED=true, use managed test users only, and do not implement arbitrary user impersonation.
32
+ ```
33
+
34
+ ## Minimal Usage
35
+
36
+ ```ts
37
+ import { betterAuth } from "better-auth";
38
+ import { createAuthClient } from "better-auth/react";
39
+ import { devtoolsPlugin, devtoolsClientPlugin } from "better-auth-devtools/plugin";
40
+
41
+ export const auth = betterAuth({
42
+ database,
43
+ plugins: [
44
+ devtoolsPlugin({
45
+ templates: {
46
+ admin: { label: "Admin", meta: { role: "admin" } },
47
+ viewer: { label: "Viewer", meta: { role: "viewer" } },
48
+ },
49
+ async createManagedUser(args) {
50
+ return { userId: "new-user-id", email: args.email, label: args.template.label };
51
+ },
52
+ async getSessionView(args) {
53
+ return {
54
+ userId: args.userId,
55
+ fields: { sessionId: args.sessionId, role: "viewer" },
56
+ editableFields: ["role"],
57
+ };
58
+ },
59
+ async patchSession(args) {
60
+ return {
61
+ userId: args.userId,
62
+ fields: { sessionId: args.sessionId, role: String(args.patch.role ?? "viewer") },
63
+ editableFields: ["role"],
64
+ };
65
+ },
66
+ }),
67
+ ],
68
+ });
69
+
70
+ export const authClient = createAuthClient({
71
+ plugins: [devtoolsClientPlugin()],
72
+ });
73
+ ```
74
+
75
+ ```tsx
76
+ "use client";
77
+
78
+ import { BetterAuthDevtools } from "better-auth-devtools/react";
79
+
80
+ export function Devtools() {
81
+ return (
82
+ <BetterAuthDevtools
83
+ enabled={process.env.NODE_ENV !== "production"}
84
+ basePath="/api/auth"
85
+ templates={["admin", "viewer"]}
86
+ editableFields={[
87
+ { key: "role", label: "Role", type: "select", options: ["admin", "viewer"] },
88
+ ]}
89
+ />
90
+ );
91
+ }
92
+ ```
93
+
94
+ ## Demo
95
+
96
+ ```bash
97
+ pnpm install
98
+ pnpm --dir apps/demo-app db:init
99
+ pnpm dev
100
+ ```
101
+
102
+ The demo app in [`apps/demo-app`](https://github.com/C-W-D-Harshit/better-auth-devtools/tree/main/apps/demo-app) is the reference integration.
103
+
104
+ ## Notes
105
+
106
+ - Managed test users only. This is not arbitrary user impersonation.
107
+ - Intended for local and trusted development environments.
108
+ - Current public API:
109
+ - `better-auth-devtools/plugin`
110
+ - `better-auth-devtools/react`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth-devtools",
3
- "version": "0.1.1-alpha.2",
3
+ "version": "0.1.1-alpha.5",
4
4
  "private": false,
5
5
  "description": "Unofficial Better Auth devtool for managed test users, session switching, and a React DevTools panel via plugin/react subpath exports.",
6
6
  "type": "module",