Skip to content

Migrating from 0.5.6 to 0.6.0

  • All imports from @erquhart/convex-better-auth have been updated to @convex-dev/better-auth. Search and replace this across your repo.
  • AuthFunctions are now passed to the BetterAuth component constructor via the config object as shown below instead of directly (more framework specific instructions here).
  • The crossDomain plugin now requires a siteUrl option.
  • The siteUrl value will be added to trustedOrigins automatically. trustedOrigins can be removed if using the cross domain plugin and your siteUrl was the only value.
  • For frontend frameworks such as React/Expo, you will not need the baseUrl in your better-auth server instance, but you will need the cross domain plugin.
convex/auth.ts
import { BetterAuth, type AuthFunctions, convexAdapter } from "@erquhart/convex-better-auth";
import { convex, crossDomain } from "@erquhart/convex-better-auth/plugins";
import { BetterAuth, type AuthFunctions, convexAdapter } from "@convex-dev/better-auth";
import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
export const betterAuthComponent = new BetterAuth(
components.betterAuth,
authFunctions,
{
authFunctions: authFunctions,
}
}
)
export const createAuth = (ctx: GenericCtx) =>
betterAuth({
trustedOrigins: ["http://localhost:3000"],
database: convexAdapter(ctx, betterAuthComponent),
plugins: [
convex(),
crossDomain(),
crossDomain({
siteUrl: "http://localhost:3000",
}),
],
});
  • For full stack framworks, if you’re using the api proxies, you can remove the cross domain plugin, but you will need to add the baseUrl to your better-auth server instance. For example, in Next.js:
convex/auth.ts
export const createAuth = (ctx: GenericCtx) =>
betterAuth({
baseUrl: "http://localhost:3000",
database: convexAdapter(ctx, betterAuthComponent),
plugins: [
//...
],
});
//...
app/api/auth/[...all]/route.ts
import { nextJsHandler } from "@convex-dev/better-auth/nextjs";
export const { GET, POST } = nextJsHandler();