Migrating from 0.5.6 to 0.6.0
Imports
Section titled “Imports”- All imports from
@erquhart/convex-better-authhave been updated to@convex-dev/better-auth. Search and replace this across your repo.
Component Setup
Section titled “Component Setup”- AuthFunctions are now passed to the BetterAuth component constructor via the config object as shown below instead of directly (more framework specific instructions here).
Cross Domain Plugin
Section titled “Cross Domain Plugin”Frontend Frameworks
Section titled “Frontend Frameworks”- The crossDomain plugin now requires a
siteUrloption. - The
siteUrlvalue will be added totrustedOriginsautomatically.trustedOriginscan be removed if using the cross domain plugin and yoursiteUrlwas the only value. - For frontend frameworks such as React/Expo, you will not need the
baseUrlin your better-auth server instance, but you will need the cross domain plugin.
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", }), ], });Full Stack Frameworks
Section titled “Full Stack Frameworks”- 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
baseUrlto your better-auth server instance. For example, in Next.js:
export const createAuth = (ctx: GenericCtx) => betterAuth({ baseUrl: "http://localhost:3000", database: convexAdapter(ctx, betterAuthComponent), plugins: [ //... ], });//...import { nextJsHandler } from "@convex-dev/better-auth/nextjs";
export const { GET, POST } = nextJsHandler();