Skip to content

fix(auth): handle prerender hydration auth state#186

Merged
onmax merged 1 commit intomainfrom
fix/auth-prerender-hydration
Feb 22, 2026
Merged

fix(auth): handle prerender hydration auth state#186
onmax merged 1 commit intomainfrom
fix/auth-prerender-hydration

Conversation

@onmax
Copy link
Collaborator

@onmax onmax commented Feb 22, 2026

Summary

  • remove middleware hydration bypass for auth-protected routes so guest/user checks still run
  • keep public routes unaffected when no auth rule is resolved
  • keep \ false during prerender hydration when SSR auth snapshot is empty
  • add focused regression tests for middleware route-rule auth handling and prerender readiness timing

Tests


  • RUN v4.0.15 /Users/maxi/nuxt/better-auth

✓ |unit| test/auth-global-middleware.test.ts (3 tests) 17ms
✓ |unit| test/use-user-session.test.ts (36 tests) 5049ms
✓ signUp does not auto-navigate to authenticated redirect when session is unresolved 5002ms

Test Files 2 passed (2)
Tests 39 passed (39)
Start at 17:53:40
Duration 5.22s (transform 103ms, setup 0ms, import 167ms, tests 5.07s, environment 0ms)

  • \

@onmax/nuxt-better-auth@0.0.2-alpha.29 lint /Users/maxi/nuxt/better-auth
eslint .

  • \

@onmax/nuxt-better-auth@0.0.2-alpha.29 typecheck /Users/maxi/nuxt/better-auth
vue-tsc --noEmit

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 22, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nuxt-modules/better-auth/@onmax/nuxt-better-auth@186

commit: 7e3569d

@onmax onmax merged commit d556d1b into main Feb 22, 2026
3 checks passed
@onmax onmax deleted the fix/auth-prerender-hydration branch February 22, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant