blog website SSR pagination
Answered
Silver posted this in #help-forum
SilverOP
Hello everyone
Im designing my frontend and i wanna implement pagination for my blog so that everything is SSR. Now my question was should I render on build or render when the page is requested ?
I feel like doing it in build will be faster
However no idea how I will implement the pagination.
The blog posts will be stored in a database
If there are some missing details just tell me what’s missing and I will try to supply the required information.
Im designing my frontend and i wanna implement pagination for my blog so that everything is SSR. Now my question was should I render on build or render when the page is requested ?
I feel like doing it in build will be faster
However no idea how I will implement the pagination.
The blog posts will be stored in a database
If there are some missing details just tell me what’s missing and I will try to supply the required information.
Answered by fuma
You can use
Read this: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering
generateStaticParams to statically generate pages at build time, like generating dynamic route /blog/[page] for the pagination implementation.Read this: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering
10 Replies
@Silver Hello everyone
Im designing my frontend and i wanna implement pagination for my blog so that everything is SSR. Now my question was should I render on build or render when the page is requested ?
I feel like doing it in build will be faster
However no idea how I will implement the pagination.
The blog posts will be stored in a database
If there are some missing details just tell me what’s missing and I will try to supply the required information.
Normally, your build result will be cached. Therefore, Regardless of how many pages you have (unless you got really a lot like thousands of articles), generating the pages during build via
generateStaticParams is always the preferred way and shouldn't have caused any significant performance issues.About pagination, you can create a dynamic route: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
Remember to generate static parameters, so that your pages will be optimized during build.
Remember to generate static parameters, so that your pages will be optimized during build.
SilverOP
Ahh, so having the page that shows all the posts being dynamic is fine and will be cached ?
How did you get this conclusion? I mean static generated page.
It will be terrible if it is dynamically rendered because data fetching can take over a second.
It will be terrible if it is dynamically rendered because data fetching can take over a second.
You can use
Read this: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering
generateStaticParams to statically generate pages at build time, like generating dynamic route /blog/[page] for the pagination implementation.Read this: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering
Answer
SilverOP
Ah I see that makes more sense
SilverOP
I understand it now Thank you
Nice! Mark my answer as the solution if your question has been solved 

Porcelaine
How did you achieve it? Can I take a look at your code?