1

I used getServerSideProps on the wrapper.

And I printed out the param(query) and it was undefined.

How do I get params(query)?

  const Home = () => {
  const router = useRouter();
  const { id } = router.query;
  return <div>{id}</div>;
};

export const getServerSideProps = wrapper.getServerSideProps(
  (store) =>
        async ({ req, res }) => {
            console.log(store.query.id) // undefined
            console.log(store.params.id) // undefined
            console.log(req.params.id) // undefined
            console.log(req.query.id) // undefined
        }
);
juliomalves
  • 42,130
  • 20
  • 150
  • 146
Yoo Guk
  • 21
  • 1
  • The same way you'd do in a regular `getServerSideProps` function (without Redux wrapper), e.g. `async ({ req, res, params, query }) => { console.log(params.id); console.log(query.id); }`. See [How to access route parameter inside getServerSideProps in Next.js?](https://stackoverflow.com/questions/69058259/how-to-access-route-parameter-inside-getserversideprops-in-next-js). – juliomalves Oct 05 '22 at 18:39
  • Isn't regular `getServerSideProps` and redux wrapper `getServerSideProps` different – Yoo Guk Oct 08 '22 at 05:20
  • Yes, the functions are different. But the inner function in `wrapper.getServerSideProps` receives the same props as `getServerSideProps`. – juliomalves Oct 08 '22 at 06:57

0 Answers0