Sean Aguinaga
Sean Aguinaga•3mo ago

Expo Example?

Not sure how to do this part: https://www.better-auth.com/docs/integrations/expo#configure-a-better-auth-backend Since it doesn't need a context? but that is needed for the convex adapter?
Expo Integration | Better Auth
Integrate Better Auth with Expo.
14 Replies
Convex Bot
Convex Bot•3mo 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!
Sean Aguinaga
Sean AguinagaOP•3mo ago
I am not sure where there are steps numbered out like that? https://convex-better-auth.netlify.app/#getting-started Not here?
Convex + Better Auth
Typesafe, secure auth for Convex apps with Better Auth
Sean Aguinaga
Sean AguinagaOP•3mo ago
Unfortuantely I do not understand how to do what you are asking
Sean Aguinaga
Sean AguinagaOP•3mo ago
https://convex-better-auth.netlify.app/#getting-started Even after following this How would you get the ctx?
Convex + Better Auth
Typesafe, secure auth for Convex apps with Better Auth
Sean Aguinaga
Sean AguinagaOP•3mo ago
import { convexAdapter } from "@convex-dev/better-auth";
import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
import { requireEnv } from "@convex-dev/better-auth/utils";
import { betterAuth } from "better-auth";
import { betterAuthComponent } from "../../convex/auth";
import { type GenericCtx } from "../../convex/_generated/server";

const siteUrl = requireEnv("SITE_URL");

export const createAuth = (ctx: GenericCtx) =>
// Configure your Better Auth instance here
betterAuth({
trustedOrigins: [siteUrl],
database: convexAdapter(ctx, betterAuthComponent),

// Simple non-verified email/password to get started
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
plugins: [
// The Convex plugin is required
convex(),

// The cross domain plugin is required for client side frameworks
crossDomain({
siteUrl,
}),
],
});
import { convexAdapter } from "@convex-dev/better-auth";
import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
import { requireEnv } from "@convex-dev/better-auth/utils";
import { betterAuth } from "better-auth";
import { betterAuthComponent } from "../../convex/auth";
import { type GenericCtx } from "../../convex/_generated/server";

const siteUrl = requireEnv("SITE_URL");

export const createAuth = (ctx: GenericCtx) =>
// Configure your Better Auth instance here
betterAuth({
trustedOrigins: [siteUrl],
database: convexAdapter(ctx, betterAuthComponent),

// Simple non-verified email/password to get started
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
plugins: [
// The Convex plugin is required
convex(),

// The cross domain plugin is required for client side frameworks
crossDomain({
siteUrl,
}),
],
});
erquhart
erquhart•3mo ago
Ah sorry, I updated that comment with a link for clarity - I meant the Better Auth docs, starting with step 4 here: https://www.better-auth.com/docs/integrations/expo#add-the-expo-plugin-on-your-server
Sean Aguinaga
Sean AguinagaOP•3mo ago
Expo Integration | Better Auth
Integrate Better Auth with Expo.
erquhart
erquhart•3mo ago
No, not necessary
Sean Aguinaga
Sean AguinagaOP•3mo ago
Does that mean I can't use convex/better-auth in their RSC/server-side components then?
erquhart
erquhart•3mo ago
No, it just means I haven't tried 🙈 If you're using Convex, though, I'd really recommend just using Convex functions, and if you really need request/response for some reason, http actions for server side code. Projects that don't use Convex have something to gain from Expo api routes, but I suspect it's just added complexity for a Convex project. This is different from web where you probably have a server anyway with a Nextjs or TanStack site for SSR, so framework server actions and functions can come into play organically. Your native app won't need SSR, so Expo api routes is just an additional server you host that you have to get working with Convex, which is already your server. If anyone feels I'm missing a use case here please point it out. Probably need compatibility regardless for folks migrating to Convex that have already built on Expo api routes.
Sean Aguinaga
Sean AguinagaOP•3mo ago
It basically lets you do RSC with native components its super sick
Sean Aguinaga
Sean AguinagaOP•3mo ago
Expo Documentation
Using React Server Components in Expo Router apps
Learn about rendering React components on the server in Expo.
Sean Aguinaga
Sean AguinagaOP•3mo ago
I think this would work for the expo api routes too?
No description

Did you find this page helpful?