{"id":4895,"date":"2024-07-08T21:43:06","date_gmt":"2024-07-08T16:13:06","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=4895"},"modified":"2024-07-08T21:43:07","modified_gmt":"2024-07-08T16:13:07","slug":"ssrserver-side-rendering-vs-csrclient-side-rendering","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/ssrserver-side-rendering-vs-csrclient-side-rendering\/","title":{"rendered":"SSR(Server Side Rendering) vs CSR(Client Side Rendering)"},"content":{"rendered":"<p>Have you ever found yourself pulling your hair out trying to understand SSR and CSR? Maybe you&#8217;ve been asked in an interview to explain SSR and CSR, their differences, and when to use each one. Or perhaps you&#8217;ve heard about Hybrid rendering, which combines both CSR and SSR, and you&#8217;re not quite sure what that means. Don&#8217;t worry\u2014let&#8217;s dive into these concepts and discuss them in detail.<\/p>\n<p><\/p>\n<p>But before moving to that we should first know the steps involved in getting a web application from development to being used by users.<\/p>\n<p><\/p>\n<h2>Process<\/h2>\n<ul>\n<li><strong>Build: <\/strong><span class=\"ql-font-monospace\">Prepare the code by compiling, bundling and optimizing it.<\/span><\/li>\n<li><strong>Server: <\/strong><span class=\"ql-font-monospace\">Host the prepared code and serve it to users.<\/span><\/li>\n<li><strong>Execution: <\/strong><span class=\"ql-font-monospace\">The user&#8217;s browser load and renders the application making it interactive.<\/span><\/li>\n<\/ul>\n<p><\/p>\n<p><strong> <\/strong>Now that you have understand the process of web application from development to users let&#8217;s dive into our topic.<\/p>\n<p><\/p>\n<h1>SSR(Server Side Rendering)<\/h1>\n<p>Server side rendering means rendering web pages on the server and sending fully rendered HTML to client.<\/p>\n<p><\/p>\n<h2>How it works:<\/h2>\n<ol>\n<li>As a user you request a web page.<\/li>\n<li>The server process the request and generates the HTML content.<\/li>\n<li>The server will then send a fully rendered HTML to your browser.<\/li>\n<li>Browser will display it&#8217;s HTML content to you.<\/li>\n<\/ol>\n<p><\/p>\n<p>That&#8217;s all about SSR and working of SSR. Now that you how it works let&#8217;s discuss it&#8217;s pros and cons:<\/p>\n<p><\/p>\n<h2>Pros<\/h2>\n<ol>\n<li><strong>Faster initial load:<\/strong> <span class=\"ql-font-monospace\">Now that you know HTML is being rendered on the server side, your browser can display the content as quickly as it receives it.<\/span><\/li>\n<li><strong>SEO:<\/strong> <span class=\"ql-font-monospace\">Search engines can easily crawl and index the fully rendered HTML.<\/span><\/li>\n<li><strong>Low-end Devices Friendly:<\/strong> <span class=\"ql-font-monospace\">Better performance on low end devices as it requires minimal processing on the client&#8217;s side.<\/span><\/li>\n<\/ol>\n<h2>Cons<\/h2>\n<ol>\n<li><strong>Server load:<\/strong> <span class=\"ql-font-monospace\">It increases the server load as most of it&#8217;s processing is done on server side.<\/span><\/li>\n<li><strong>Slow Interaction:<\/strong> <span class=\"ql-font-monospace\">After the initial load further Interaction will require more communication with the server.<\/span><\/li>\n<\/ol>\n<p><\/p>\n<p><\/p>\n<h1>CSR(Client Side Rendering)<\/h1>\n<p>Client side rendering means rendering web pages on the browser side using Javascript.<\/p>\n<p><\/p>\n<p>How it works:<\/p>\n<ol>\n<li>As a user you request a web page.<\/li>\n<li>The server sends a minimal HTML file along with JS to the client.<\/li>\n<li>The browser downloads and executes the JS and generates the HTML dynamically.<\/li>\n<li>Browser will display content to you.<\/li>\n<\/ol>\n<p><\/p>\n<p>Now that you how it works let&#8217;s discuss it&#8217;s pros and cons:<\/p>\n<p><\/p>\n<h2>Pros<\/h2>\n<ol>\n<li><strong>Better Interactivity: <\/strong><span class=\"ql-font-monospace\">Faster interaction as it processing happens at client side.<\/span><\/li>\n<li><strong> Server load: <\/strong><span class=\"ql-font-monospace\">It reduces server load as server sends static files.<\/span><\/li>\n<li><strong>User experience: <\/strong><span class=\"ql-font-monospace\">User experience is better as dynamic content updates happen without page reloads.<\/span><\/li>\n<\/ol>\n<h2>Cons<\/h2>\n<ol>\n<li><strong>Slower initial load:<\/strong> <span class=\"ql-font-monospace\">As processing happens on client side it&#8217;s obvious that it will take longer time.<\/span><\/li>\n<li><strong>SEO:<\/strong> <span class=\"ql-font-monospace\">Seo challenges will be there as Search engines might have difficulty indexing content that is dynamically rendered.<\/span><\/li>\n<li><strong>Usage:<\/strong> <span class=\"ql-font-monospace\">Resource usage is generally high as processing happens on your(client&#8217;s) device.<\/span><\/li>\n<\/ol>\n<p><\/p>\n<p>Both SSR and CSR have their use cases, and often today&#8217;s modern applications use a combination of both (called <strong>hybrid rendering<\/strong>) to leverage the benefits of each approach.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever found yourself pulling your hair out trying to understand SSR and CSR? Maybe you&#8217;ve been asked in an interview to explain SSR and CSR, their differences, and when to use each one. Or perhaps you&#8217;ve heard about Hybrid rendering, which combines both CSR and SSR, and you&#8217;re not quite sure what that<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[362,263,350,361],"tags":[347,223],"class_list":["post-4895","post","type-post","status-publish","format-standard","category-client-side-rendering","category-javascript-frameworks","category-nextjs","category-server-side-rendering","tag-nextjs","tag-reactjs"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=4895"}],"version-history":[{"count":1,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4895\/revisions"}],"predecessor-version":[{"id":4897,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4895\/revisions\/4897"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=4895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=4895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=4895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}