SacredGamer
SacredGamer11h ago

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);
// 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
3 Replies
Convex Bot
Convex Bot11h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Wayne
Wayne11h ago
@SacredGamer hi can you ask in the #better-auth channel?
erquhart
erquhart8h ago
Data is being persisted, you're looking at the app tables. Components have their own tables. When you're looking at the data view in the dashboard, there's a dropdown in the top left where you can select "betterAuth" to see auth tables.

Did you find this page helpful?