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

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