nextjs-use-react-navigation
#
Installation#
API#
useRouterNavigationExposes stable methods for the navigation methods of NextJS router
#
useRouterQueryNice way of accessing type-safe router.params
. By default, the type is narrowed to returning
string | undefined
instead of the next.js default of string[] | string | undefined
. This makes
it a bit nicer to use, avoiding the need for checking if the variable is string[]
.
You can also pass in a type shape, useful if you expect a key to be an array after all.
You can pass in a string union as a convenience when you only expect params to be of string, but want to type-check access
#
useRouterQueryForUrlAn enhanced useRouterQuery
hook that looks at your URL and adds the URL param tokens as required
keys in the returned object, and allows you to specify the possible query params that might be
passed as well. The second type argument functions exactly as the initial type argument found on
useRouterQuery
.
Or, with a more complex type shape