Ssr vs Csr
Server side rendering vs Client side rendering
When user sends a request to a server, different server responses differently depending on the implementations.
Server side rendering
Whenever you visit a website, your browser makes a request to the server. Once the request is done processing, your browser gets back the fully rendered HTML and displays it on the screen. If you then decide to visit a different page on the website, your browser will once again make another request for the new information. This will occur each and every time you visit a page that your browser does not have a cached version of.
It doesn’t matter if the new page only has a few items that are different than the current page, the browser will ask for the entire new page and will re-render everything from the ground up.
Pros
- Better SEO
- The initial page load is faster
- Good for static sties
Cons
- Frequent server requests
- Overall slow page rendering
- Full page reloads
- Non-rich site interactions.
Client side rendering
Basically rendering content in the browser using JavaScript. Instead of getting all of the content from the HTML document itself, you are getting a bare-bones HTML document with a JavaScript file that will render the rest of the site using the browser.
This is much faster since you are only loading a very small section of the page to fetch the new content, instead of loading the entire page.
Pros
- Rich site interactions
- Fast website rendering after the initial load
- No full page reloads
- Great for web applications (Next.js)
Cons
- Low SEO
- Initial load might require more time