How can I get (query string) parameters from the URL in Next.js?

后端 未结 8 565
情深已故
情深已故 2020-12-13 01:32

When I click on a link in my /index.js, it brings me to /about.js page.

However, when I\'m passing parameter name through URL (like

8条回答
  •  被撕碎了的回忆
    2020-12-13 02:16

    import { useRouter } from 'next/router';
    
    function componentName() {
        const router = useRouter();
        console.log('router obj', router);
    }
    

    We can find the query object inside a router using which we can get all query string parameters.

提交回复
热议问题