The Wayback Machine - https://web.archive.org/web/20221230042553/https://github.com/vercel/next.js/discussions/17529
Skip to content

Why can't I get query params in getStaticProps? #17529

Answered by lfades
alioshr asked this question in Help
Discussion options

You must be logged in to vote

getStaticProps generates the page at build time. There's no possible way to know the custom query params your visitors can use at build time.

getInitialProps and getServerSideProps can know all the possible query params because the page is generated at runtime, whenever you receive a new request.

You can learn more about the above here: https://nextjs.org/docs/basic-features/pages#two-forms-of-pre-rendering

Replies: 2 suggested answers 3 replies

Comment options

You must be logged in to vote
3 replies
@alioshr
Comment options

@lucasbasquerotto
Comment options

@edoardo-bluframe
Comment options

Answer selected by lfades
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants