I'm trying to create a simple routing test in a Next.js application using Dynamic Routes
As part of my test I have created pages/test/[id].js
with the following code:
import { useRouter } from 'next/router'
export default function Test() {
const router = useRouter()
console.log(router)
return <p />
}
However, when hitting the URL test/foo?a=1
I see the following in console:
ServerRouter {
route: '/test/[id]',
pathname: '/test/[id]',
query: {},
asPath: '/test/[id]',
basePath: '',
events: undefined,
isFallback: false,
locale: undefined,
isReady: false,
locales: undefined,
defaultLocale: undefined,
domainLocales: undefined,
isPreview: false,
isLocaleDomain: false
}
Question is, I'm expecting to see something here, particularly in query
. What's missing here?