TypeScript types
Primary imports
import type {
AuthUser,
AuthSession,
AuthMeta,
AuthRouteRules,
RequireSessionOptions,
AuthSocialProviderId,
} from '#nuxt-better-auth'Key guarantees
AuthUserandAuthSessionare inferred from your Better Auth config.- plugin fields flow into
useUserSession(),getUserSession(),getRequestSession(),requireUserSession(), and auth route matching. AuthSocialProviderIdis inferred from configured social providers.
Manual augmentation
Only add manual module augmentation if inference is not enough or you need to declare project-specific fields in advance.
import '#nuxt-better-auth'
declare module '#nuxt-better-auth' {
interface AuthUser {
customField?: string
}
}Type-safe user matching
await requireUserSession(event, {
user: { role: 'admin' },
})The same user matcher shape works in route rules and page meta.