MCPcopy
hub / github.com/vercel/next.js / useRouter

Function useRouter

packages/next/src/client/router.ts:138–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 * Read more: [Next.js Docs: `useRouter`](https://nextjs.org/docs/pages/api-reference/functions/use-router)
137 */
138export function useRouter(): NextRouter {
139 const router = React.useContext(RouterContext)
140 if (!router) {
141 throw new Error(
142 'NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted'
143 )
144 }
145
146 return router
147}
148
149/**
150 * Create a router and assign it as the singleton instance.

Callers 15

WithRouterWrapperFunction · 0.90
RouteAnnouncerFunction · 0.90
FormFunction · 0.90
index.jsFile · 0.90
EditPetFunction · 0.90
PageFunction · 0.90
something.jsFile · 0.90
index.jsFile · 0.90
SlugFunction · 0.90
[slug].jsFile · 0.90
[...slug].jsFile · 0.90
[slug].jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected