Replies: 10 comments 11 replies
-
If you do have a dynamic path and only want one page generated at build time and the rest a request time, just hard code that option as the return value for paths. The single page you define will be generated at build time, and then if a request comes in for any of the other pages, that's where |
Beta Was this translation helpful? Give feedback.
-
@leerob Hi, is it possible to get the current page route inside getStaticProps? e.g I have some pages which use a shared |
Beta Was this translation helpful? Give feedback.
-
I can see it being particularly useful for generating translation files (that do not depend on |
Beta Was this translation helpful? Give feedback.
-
I have also run into this issue. In my case I have a dynamic route that requires authentication (e.g. |
Beta Was this translation helpful? Give feedback.
-
My suggestion here would be for Next to add handling for a function named something like |
Beta Was this translation helpful? Give feedback.
-
is there any solution now? |
Beta Was this translation helpful? Give feedback.
-
Same use case as @MikeyZat! |
Beta Was this translation helpful? Give feedback.
-
Any solution now? |
Beta Was this translation helpful? Give feedback.
-
Some ideas from SO: https://stackoverflow.com/questions/71293075/how-to-use-dynamic-routes-without-getstaticpaths |
Beta Was this translation helpful? Give feedback.
-
I've found the following solution.
I want export default function BlogItem() {
const router = useRouter();
const id = router.query.id;
// fetch blog data by 'id' in useEffect()
return <div>Blog item: {id}</div>;
} I can achieve that with 3 steps:
|
Beta Was this translation helpful? Give feedback.
-
From the docs about getStaticPaths:
But what if the data I want to be embedded in the page does not depend on the path parameter ? I want only one page to be generated at build time (I do not want to generate a list of pages based on the result of
getStaticPaths
) and I do not want to opt-out of Automatic Static Generation.Is it possible ? I do not think setting
fallback: true
in the return value ofgetStaticPaths
is what I am looking for, since I still want the page to be generated at build time.Beta Was this translation helpful? Give feedback.
All reactions