Skip to content

Conversation

@molefrog
Copy link
Owner

@molefrog molefrog commented Nov 25, 2025

Fixes #446

When ssrPath/ssrSearch props are not provided during client-side hydration, use
location.pathname and location.search as the SSR snapshot instead of defaulting to
empty strings. This ensures hydration matches the server-rendered output.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@molefrog molefrog force-pushed the fix/ssr-search-hydration-error branch 2 times, most recently from 6f96aa7 to ac2a40f Compare November 25, 2025 10:39
When rendering on the client without ssrPath/ssrSearch props, usePathname and useSearch now use location.pathname and location.search as the SSR snapshot instead of defaulting to empty strings. This ensures the client-side hydration matches what was rendered on the server.
@molefrog molefrog force-pushed the fix/ssr-search-hydration-error branch from ac2a40f to c7aceb5 Compare November 25, 2025 10:41
@github-actions
Copy link

size-limit report 📦

Path Size
packages/wouter/src/index.js 2.19 KB (+0.05% 🔺)
packages/wouter/src/use-browser-location.js 523 B (-0.58% 🔽)
packages/wouter/src/memory-location.js 799 B (0%)
packages/wouter/src/use-hash-location.js 720 B (0%)
packages/wouter-preact/src/index.js 2.08 KB (0%)
packages/wouter-preact/src/use-browser-location.js 460 B (0%)
packages/wouter-preact/src/use-hash-location.js 646 B (0%)
packages/wouter-preact/src/memory-location.js 721 B (0%)

@molefrog molefrog merged commit a8771aa into v3 Nov 25, 2025
2 checks passed
@molefrog molefrog deleted the fix/ssr-search-hydration-error branch November 25, 2025 10:42
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.

Using useSearch with SSR throws a hydration warning

2 participants