Skip to content

Commit 152f51c

Browse files
authored
Avoid breaking useRouter() type change (#42430)
Since `useRouter()` can still be used in `pages` alone and should always be a valid instance we shouldn't change the default return type to avoid a breaking type change. Fixes: #42409 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 8fa78a5 commit 152f51c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/next/client/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default singletonRouter as SingletonRouter
130130
export { default as withRouter } from './with-router'
131131

132132
export function useRouter(throwOnMissing: true): NextRouter
133-
export function useRouter(): NextRouter | null
133+
export function useRouter(): NextRouter
134134
export function useRouter(throwOnMissing?: boolean) {
135135
const router = React.useContext(RouterContext)
136136
if (!router && throwOnMissing) {

0 commit comments

Comments
 (0)