Migrate from 1.6 to 1.7
Update consumer imports, server helpers, types, and copied components for Better Auth UI 1.7.
Better Auth UI 1.7 changes several public import paths. Most applications must update consumer code, even when their authentication configuration does not change.
Upgrade Better Auth at the same time
Better Auth UI 1.7 requires Better Auth 1.7 or newer. An older Better Auth version can cause many unrelated TypeScript errors after this migration.
Consumer changes at a glance
| Consumer code | Required change |
|---|---|
| Core plugin APIs | Replace @better-auth-ui/core/plugins with @better-auth-ui/core/plugins/<plugin> |
| React and Solid plugin hooks | Import from @better-auth-ui/react/plugins/<plugin> or @better-auth-ui/solid/plugins/<plugin> |
| Query and mutation option factories | Import shared factories from core and plugin factories from a core plugin path |
| Auth client types | Import shared types from core and plugin types from a core plugin path |
| Server helpers | Replace the React or Solid server path with a core server path |
| Solid auth client | Import createAuthClient from better-auth/solid |
| Copied registry components | Refresh them and merge the 1.7 changes with local customizations |
Update consumer code
Find imports that need changes
Search your application and any internal packages:
rg '"@better-auth-ui/(core|react|solid)/plugins"' .
rg '"@better-auth-ui/(react|solid)/server"' .Also search for APIs that moved or changed names:
rg '\b(AuthClient|createAuthClient|sessionOptions|ensureSession|prefetchSession|fetchSession)\b' .Ignore generated output and dependency folders in the results.
Replace core plugin aggregate imports
The @better-auth-ui/core/plugins entry point no longer exists. Import each API from its plugin entry point.
import {
type OrganizationLocalization,
organizationPlugin,
organizationQueryKeys
} from "@better-auth-ui/core/plugins"import {
type OrganizationLocalization,
organizationPlugin,
organizationQueryKeys
} from "@better-auth-ui/core/plugins/organization"Use the plugin name at the end of the path. For example, use /plugins/api-key, /plugins/passkey, /plugins/two-factor, or /plugins/organization.
If one import contains APIs from different plugins, split it into one import for each plugin.
Move plugin hooks out of the framework root
Shared hooks remain in @better-auth-ui/react and @better-auth-ui/solid. Plugin hooks now use a plugin entry point.
import {
useActiveOrganization,
useInviteMember,
useListOrganizations,
useSession
} from "@better-auth-ui/react"import { useSession } from "@better-auth-ui/react"
import {
useActiveOrganization,
useInviteMember,
useListOrganizations
} from "@better-auth-ui/react/plugins/organization"Use the same pattern with @better-auth-ui/solid/plugins/<plugin> in a Solid application.
Move option factories and auth client types to core
Version 1.7 makes query and mutation option factories framework-independent. Import shared factories and types from @better-auth-ui/core.
import {
type AuthClient,
sessionOptions,
signOutOptions
} from "@better-auth-ui/react"import {
type AuthClient,
sessionOptions,
signOutOptions
} from "@better-auth-ui/core"Import plugin factories and client types from the matching core plugin path:
import {
type OrganizationAuthClient,
inviteMemberOptions,
listOrganizationsOptions
} from "@better-auth-ui/core/plugins/organization"Keep framework hooks in the React or Solid package. For example, useSession remains in the framework root, and useListOrganizations moves to the framework organization entry point.
Move server helpers and rename session helpers
The React and Solid /server entry points no longer exist. Import shared server APIs from @better-auth-ui/core/server.
The session helper names now use a Server suffix:
| 1.6 name | 1.7 name |
|---|---|
sessionOptions | sessionOptionsServer |
ensureSession | ensureSessionServer |
prefetchSession | prefetchSessionServer |
fetchSession | fetchSessionServer |
import {
ensureSession,
sessionOptions
} from "@better-auth-ui/react/server"import {
ensureSessionServer,
sessionOptionsServer
} from "@better-auth-ui/core/server"Plugin server APIs use a plugin-specific core path. Their existing function names remain unchanged.
import {
ensureActiveOrganization,
listOrganizationsOptions
} from "@better-auth-ui/react/server"import {
ensureActiveOrganization,
listOrganizationsOptions
} from "@better-auth-ui/core/plugins/organization/server"Version 1.7 provides server entry points for API key, magic link, multi-session, organization, passkey, and username.
Update Solid auth client imports
If a Solid source file imports createAuthClient from Better Auth UI, import it from Better Auth instead.
import { createAuthClient } from "@better-auth-ui/solid"import { createAuthClient } from "better-auth/solid"Refresh copied components
If you installed shadcn/ui components, the source files are part of your application. A package update does not update those files.
Inspect the registry changes first:
bunx --bun shadcn@latest add @better-auth-ui/all --dry-run
bunx --bun shadcn@latest add @better-auth-ui/all --diffThen refresh only the groups that your application uses. Merge the changes with your local customizations.
bunx --bun shadcn@latest add @better-auth-ui/auth @better-auth-ui/settings
bunx --bun shadcn@latest add @better-auth-ui/organization@better-auth-ui/organization is a shadcn registry item. It is not an npm package.
If you use Zaidan, inspect the matching Solid registry entries before you replace local files:
bunx --bun shadcn@latest add https://better-auth-ui.com/r/solid/auth.json --dry-run
bunx --bun shadcn@latest add https://better-auth-ui.com/r/solid/organization.json --dry-runRemove --dry-run after you review the changes. HeroUI components come from @better-auth-ui/heroui, so they do not need this copied-component step.
Align dependencies
After you update the consumer code, keep the authentication packages on compatible versions:
- Use
better-auth1.7.0 or newer. - Use Better Auth UI packages from the same 1.7 release.
- Update each installed Better Auth plugin package to 1.7.0 or newer. This includes
@better-auth/api-key,@better-auth/oauth-provider, and@better-auth/passkeywhen you use them. - Use TanStack Query 5.101.2 or newer.
For a React application, the main update is:
bun add @better-auth-ui/core@^1.7.0 @better-auth-ui/react@^1.7.0 \
better-auth@^1.7.0 @tanstack/query-core@^5.101.2 \
@tanstack/react-query@^5.101.2For a Solid application, the main update is:
bun add @better-auth-ui/core@^1.7.0 @better-auth-ui/solid@^1.7.0 \
better-auth@^1.7.0 @tanstack/query-core@^5.101.2 \
@tanstack/solid-query@^5.101.2 solid-js@^1.9.14Add @better-auth-ui/heroui@^1.7.0 for HeroUI. Update only the separate Better Auth plugin packages that your application already uses.
Validate the migration
Check that the dependency tree contains compatible Better Auth versions:
bun pm why better-auth
bun pm why @better-auth-ui/coreSearch for removed paths again. Both commands must return no source imports:
rg '"@better-auth-ui/(core|react|solid)/plugins"' .
rg '"@better-auth-ui/(react|solid)/server"' .Run your typecheck, linter, tests, and production build. Then test the authentication flows that your application uses, including sign-in, account settings, organizations, passkeys, and API keys.
Common migration errors
Package subpath is not exported
A source file still imports an aggregate 1.6 path. Replace it with the applicable plugin-specific 1.7 path.
Auth client types are incompatible
First, verify that better-auth and its separate plugin packages use version 1.7 or newer. Then verify that every Better Auth UI package uses version 1.7.
If the versions match, update your copied components. Old registry files can keep 1.6 imports and types in your application.
A Better Auth client method is missing
Add the matching Better Auth client plugin. For example, organization hooks require organizationClient() from better-auth/client/plugins.
The organization installer does not resolve
Run the registry installer:
bunx --bun shadcn@latest add @better-auth-ui/organizationDo not install @better-auth-ui/organization with a package manager. It is a registry item, not a package.
Postpone the migration
If you cannot update the full integration, restore the complete pre-upgrade state. Restore package.json, bun.lock, and copied component files together.
The last 1.6 release is 1.6.45. Do not combine 1.6 packages with 1.7 copied components.
Last updated on