0
votes

I was reading about Automatic Static Optimization and I came across this little section that says:

So according to this docs

During prerendering, the router's query object will be empty since we do not have query information to provide during this phase. After hydration, Next.js will trigger an update to your application to provide the route parameters in the query object.

Note: Parameters added with dynamic routes to a page that's using getStaticProps will always be available inside the query object.

The first paragraph says that the query object will be empty but the NOTE section says that it will always have available the parameters.

So what rule applies here?

1
What are you trying to accomplish? - shanemacbride
@shanemacbride To understand what the doc means - George Paouris

1 Answers

0
votes

This comes from the caveats section of dynamic-routes in the docs

Pages that are statically optimized by Automatic Static Optimization will be hydrated without their route parameters provided, i.e query will be an empty object ({}).

After hydration, Next.js will trigger an update to your application to provide the route parameters in the query object.

And also have a look at this issue where the exact behavior of the query object being empty before hydration is discussed as correct behavior by the co-author.