Skip to content

Commit 9a95fef

Browse files
committed
init
1 parent caa423d commit 9a95fef

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
# Better Auth Convex
22

3-
True local installation of Better Auth in your Convex app schema, eliminating component isolation and `ctx.runQuery`/`ctx.runMutation` overhead.
3+
Local installation of Better Auth directly in your Convex app schema, with direct database access instead of component-based queries.
44

55
## Why Better Auth Convex?
66

7-
The official `@convex-dev/better-auth` component stores auth tables in an isolated component schema. While the docs mention ["local install"](https://convex-better-auth.netlify.app/local-install), it's still component-isolated, not truly local to your app.
7+
The official `@convex-dev/better-auth` component stores auth tables in a component schema. This package provides an alternative approach with direct schema integration.
88

9-
**This package provides actual local installation:**
9+
**This package provides direct local installation:**
1010

11-
1. **Auth tables live in YOUR app schema** - Not in a component boundary
11+
1. **Auth tables live in your app schema** - Not in a component boundary
1212
2. **Direct database access** - No `ctx.runQuery`/`ctx.runMutation` overhead (>50ms latency that increases with app size)
1313
3. **Unified context** - Auth triggers can directly access and modify your app tables transactionally
1414
4. **Full TypeScript inference** - Single schema, single source of truth
1515

1616
> [!WARNING]
17-
> BREAKING CHANGE from @convex-dev/better-auth
18-
>
19-
> Auth tables are stored in your app schema instead of the component schema. If you're already in production with `@convex-dev/better-auth`, you'll need to write a migration script to move your auth data.
17+
> BREAKING CHANGE: Auth tables are stored in your app schema instead of the component schema. If you're already in production with `@convex-dev/better-auth`, you'll need to write a migration script to move your auth data.
2018
2119
## Prerequisites
2220

@@ -56,7 +54,7 @@ import schema from './schema'; // YOUR app schema with auth tables
5654
// 1. Internal API functions for auth operations
5755
const authFunctions: AuthFunctions = internal.auth;
5856

59-
// 2. Auth client with triggers that run in YOUR app context
57+
// 2. Auth client with triggers that run in your app context
6058
export const authClient = createClient<DataModel, typeof schema>({
6159
authFunctions,
6260
schema,
@@ -167,7 +165,7 @@ export default http;
167165
// ✅ In queries/mutations: Use getAuth (direct DB access)
168166
export const someQuery = query({
169167
handler: async (ctx) => {
170-
const auth = getAuth(ctx); // No ctx.runQuery overhead!
168+
const auth = getAuth(ctx); // Direct DB access
171169
const user = await auth.api.getUser({ userId });
172170
},
173171
});
@@ -185,15 +183,15 @@ export const someAction = action({
185183

186184
```ts
187185
// Component approach (@convex-dev/better-auth):
188-
// Auth tables in components.betterAuth schema (isolated)
189-
// ❌ Can't join auth tables with app tables
190-
// ❌ ctx.runQuery/runMutation overhead (>50ms)
186+
// - Auth tables in components.betterAuth schema
187+
// - Requires ctx.runQuery/runMutation for auth operations
188+
// - Component boundaries between auth and app tables
191189

192190
// Local approach (better-auth-convex):
193-
// ✅ Auth tables in YOUR app schema
191+
// ✅ Auth tables in your app schema
194192
// ✅ Direct queries across auth + app tables
195193
// ✅ Single transaction for complex operations
196-
//No component overhead
194+
//Direct function calls
197195
```
198196

199197
### Helper Functions

0 commit comments

Comments
 (0)