You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The best example will be to compare this to Gatsby.js. Gatsby has pages and templates. Templates could be used in order to programmatically generate pages during the build time. It helps to solve the problem when the website uses CMS and wants to have CMS driven routes.
Why not use Gatsby?
Gatsby dev/prod experience is not great when it comes to real projects with more than 30-40 pages, build time is slow. So having Next.js as a solution to generate pages on-demand will work much better.
How should it look like?
Based on the URL user requested for example "/solutions/cards" we have a logic that will map that URL to a specific template that has to be used to render it. The template itself could have getServerSideProps or getStaticProps, basically everything that page has. The rendered pages could be generated either on build time or run time. So if we create a new page in CMS with the template "Solutions", the first time we visit the page we generate a static version of it.
Describe the solution you'd like
Next.js introduced getStaicPaths fallback: blocking option. It partially solves the problem, but it can't be used well when we have cach-all routes [[..slug]].js with multiple numbers of Components that should be used based on the URL user requested.
At this moment if you use catch-all routes with multiple components you have to import all of them in a single file and then have switch condition whether you will use one of those components based on the requested URL. So it increases bundle size.
As an alternative, you use dynamic imports but in that case, you ruin serverside rendering.
I see that there could be a way to pass to getStaticPaths extra component parameter or create a separate concept of templates that will work independently.
This discussion was converted from issue #21171 on January 16, 2021 15:17.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the feature you'd like to request
The best example will be to compare this to Gatsby.js. Gatsby has pages and templates. Templates could be used in order to programmatically generate pages during the build time. It helps to solve the problem when the website uses CMS and wants to have CMS driven routes.
Why not use Gatsby?
Gatsby dev/prod experience is not great when it comes to real projects with more than 30-40 pages, build time is slow. So having Next.js as a solution to generate pages on-demand will work much better.
How should it look like?
Based on the URL user requested for example
"/solutions/cards"
we have a logic that will map that URL to a specific template that has to be used to render it. The template itself could have getServerSideProps or getStaticProps, basically everything that page has. The rendered pages could be generated either on build time or run time. So if we create a new page in CMS with the template "Solutions", the first time we visit the page we generate a static version of it.Describe the solution you'd like
Next.js introduced getStaicPaths fallback: blocking option. It partially solves the problem, but it can't be used well when we have cach-all routes [[..slug]].js with multiple numbers of Components that should be used based on the URL user requested.
At this moment if you use catch-all routes with multiple components you have to import all of them in a single file and then have
switch
condition whether you will use one of those components based on the requested URL. So it increases bundle size.As an alternative, you use dynamic imports but in that case, you ruin serverside rendering.
I see that there could be a way to pass to getStaticPaths extra component parameter or create a separate concept of templates that will work independently.
Describe alternatives you've considered
Gatsby
Beta Was this translation helpful? Give feedback.
All reactions