V
V
vovashaplin2020-08-06 19:41:03
React
vovashaplin, 2020-08-06 19:41:03

Working with NextJS? When to use SSG and when to use SSR?

I am making an online store on NextJS with rest api via python. There are:
- the main page (just informative);
- page with products, pagination, sorting and search
- shopping cart
- page with order filling
- page for changing user data
- registration and login
- admin panel for changing and adding products
When to use SSR (getServerSideProps) and SSG (getStaticProps and getStaticPaths)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vovashaplin, 2020-08-13
@vovashaplin

Static - automatic generation of statics without data (just html without data from the server)
SSG - automatic generation of statics and JSON with data (html with json, in which data was entered during the build)
SSR - rendering on the server side at the moment before showing the page (request to the server -> data arrival -> showing the page to the user)
SSG ( getStaticProps and getStaticPaths ) is needed to show pages or product pages only if the data on these pages does not change so often, because you need to build every time after changing the data on the DB. But this method is very fast.
But if your data changes frequently, you or the customer frequently update the content of pages and products, then SSR ( getServerSideProps ) will come to the rescue. This method is slower than SSG, but faster than default client-side request (SPA).
- main page (just informative) Static or SSG
- page with products, pagination, sorting and search SSR or SSG
- shopping cart SSR
- order filling page SSR
- page for changing user data SSR
- registration and login SSR
- admin panel for editing and adding goods SSR
If there are amendments or think that I'm wrong somewhere, write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question