SacredGamerS
Convex Community4mo ago
4 replies
SacredGamer

Better Auth + Convex Integration Issue: Users Not Persisting to Database

Convex + Better Auth Integration Issue (React Native/Expo)

Environment:
- React Native/Expo app
- better-auth@1.3.23, @better-auth/expo@1.3.23, @convex-dev/better-auth@0.8.6, convex@1.27.3 (all latest)

Problem:
Authentication works (signup, signin, tokens generated) but users are NOT persisted to Convex database. Better Auth appears to use in-memory storage fallback.

Setup (following official docs):
✅ convex.config.ts with Better Auth component
✅ auth.config.ts configured
✅ convex/auth.ts with authComponent.adapter(ctx)
✅ HTTP routes via authComponent.registerRoutes()
✅ Environment variables (BETTER_AUTH_SECRET, CONVEX_SITE_URL, EXPO_PUBLIC_CONVEX_SITE_URL)
✅ Schema includes all tables (user, account, session, verification)
✅ Direct Convex mutations work

What happens:
1. User signs up via /api/auth/sign-up/email
2. Better Auth returns success with user ID/token
3. User can sign in successfully
4. BUT: Convex tables remain empty (verified via dashboard)
5. Better Auth recognizes returning users ("existing email") without database persistence

Code:
// convex/auth.ts
export const authComponent = createClient<DataModel>(components.betterAuth);
export const createAuth = (ctx: GenericCtx<DataModel>, { optionsOnly } = { optionsOnly: false }) => {
  return betterAuth({
    baseURL: process.env.SITE_URL,
    trustedOrigins: ["edgame://"],
    database: authComponent.adapter(ctx),
    emailAndPassword: { enabled: true, requireEmailVerification: false },
    plugins: [expo(), convex()],
  });
};

// convex/http.ts
authComponent.registerRoutes(http, createAuth);


Confirmed:
- Adapter never called for DB operations
- Sessions work only until restart (in-memory)
- Direct Convex writes work fine

Question: Is this a known React Native/Expo integration issue? The adapter isn't being called. Any specific RN/Expo configuration needed? This makes the integration unusable for production apps.

cc: @Wayne
Was this page helpful?