I have an old NextJs app using pages router.
I want to use useSearchParams from next/navigation to get query parameters and apply default values to a react-hook-form input.
But at page load, useSearchParams doesn’t get query params (size = 0). Since the app is wrapped with , the same result is apply a second time.
But (again) the page is rerendered a 3 time (and a 4th with ) and this time useSearchParams contains query params. However, the input register with react-hook-form doesn’t contain the query param as default value.
Here’s a (not?) working example : https://codesandbox.io/p/devbox/s9f7lz