Migrating from 0.5.6 to 0.6.0
Imports
Section titled “Imports”- All imports from
@erquhart/convex-better-auth
have 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
siteUrl
option. - The
siteUrl
value will be added totrustedOrigins
automatically.trustedOrigins
can be removed if using the cross domain plugin and yoursiteUrl
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.
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
baseUrl
to 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();