You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, better-auth/minimal only exports BetterAuthOptions and betterAuth. It does not export User or Session.
The correct import should be from the main package:
importtype{User,Session}from'better-auth';
Impact
With skipLibCheck: true (SvelteKit default), the failed import is silently swallowed and both User and Session fall back to any. This means event.locals.user and event.locals.session are typed as any throughout the entire application — a critical type-safety hole.
With skipLibCheck: false, the actual error surfaces:
Module '"better-auth/minimal"' has no exported member 'Session'.
Reproduction
Create a fresh SvelteKit project with npx sv create
Run npx sv add better-auth
Check the generated src/app.d.ts
The import path is better-auth/minimal but that module doesn't export User/Session
Fix
In packages/sv/src/addons/better-auth.ts, change the import line from:
- import type { User, Session } from 'better-auth/minimal';+ import type { User, Session } from 'better-auth';
Additional context
This may be related to migrate better-auth to 1.6 #969 (better-auth 1.6 migration). Newer versions of better-auth may have changed the internal module structure.
The better-auth/minimal submodule (checked at better-auth@1.4.21) only exports BetterAuthOptions and betterAuth — User and Session are only available from the main entry point.
Describe the bug
Running
npx sv add better-authgeneratessrc/app.d.tswith:However,
better-auth/minimalonly exportsBetterAuthOptionsandbetterAuth. It does not exportUserorSession.The correct import should be from the main package:
Impact
With
skipLibCheck: true(SvelteKit default), the failed import is silently swallowed and bothUserandSessionfall back toany. This meansevent.locals.userandevent.locals.sessionare typed asanythroughout the entire application — a critical type-safety hole.With
skipLibCheck: false, the actual error surfaces:Reproduction
npx sv createnpx sv add better-authsrc/app.d.tsbetter-auth/minimalbut that module doesn't exportUser/SessionFix
In
packages/sv/src/addons/better-auth.ts, change the import line from:Additional context
better-authto1.6#969 (better-auth 1.6 migration). Newer versions ofbetter-authmay have changed the internal module structure.better-auth/minimalsubmodule (checked atbetter-auth@1.4.21) only exportsBetterAuthOptionsandbetterAuth—UserandSessionare only available from the main entry point.