Dynamic params for Router #17449
-
How can I pass any params on a route without implementing more params in getStaticPaths e.g
Is there any solution that I could implement any id parameters in just a single params. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
My experience is return nothing :D
Just that, this save tons of build time :D export async function getStaticPaths() { const listID=queryDatabaseFunc.findIDs() // return [1,4,5,6,7,9] return {params:{id}} return { |
Beta Was this translation helpful? Give feedback.
-
Awh getInitialProps solves it |
Beta Was this translation helpful? Give feedback.
My experience is return nothing :D
Just that, this save tons of build time :D
fallback: true,
will do the restif you still want? Use array then map it.
You will need query list of post ID in database something like this
export async function getStaticPaths() {
const listID=queryDatabaseFunc.findIDs() // return [1,4,5,6,7,9]
const myListParam= listID.map(id=>{
return {params:{id}}
})
return {
paths: myListParam;
}