<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sridhar P</title>
    <description>The latest articles on Forem by Sridhar P (@sridhar_p).</description>
    <link>https://forem.com/sridhar_p</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2933139%2F54e8c58a-ae8e-41b0-b3b9-56792b8a81ad.png</url>
      <title>Forem: Sridhar P</title>
      <link>https://forem.com/sridhar_p</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sridhar_p"/>
    <language>en</language>
    <item>
      <title>Introduction to Next.js and Setting up Next.js locally</title>
      <dc:creator>Sridhar P</dc:creator>
      <pubDate>Tue, 11 Mar 2025 23:00:59 +0000</pubDate>
      <link>https://forem.com/sridhar_p/introduction-to-nextjs-and-setting-up-nextjs-locally-1ckg</link>
      <guid>https://forem.com/sridhar_p/introduction-to-nextjs-and-setting-up-nextjs-locally-1ckg</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;React Client-Side Rendering&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React is mainly used for designing single-page applications(SPA), and it excels in creating interactive UIs. React primarily uses client-side rendering(CSR), which means the browser requests the react server for &lt;code&gt;index.html&lt;/code&gt;, and react server responds with the following &lt;code&gt;index.html&lt;/code&gt;. This HTML doesn't include any actual content of the page. Then, the browser checks for the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag in the &lt;code&gt;index.html&lt;/code&gt; and requests for the JavaScript/TypeScript files, which will be given by the React development server. After receiving the JS/TS files, the browser starts to execute them, which is where React takes over and renders the components into the specified &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgubu6a9elifwqthokjf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgubu6a9elifwqthokjf1.png" alt="Minimal HTML from React Server" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgc3oqtcvmetoysfwxi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgc3oqtcvmetoysfwxi4.png" alt="React Client-Side Rendering" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem with React CSR&lt;/strong&gt;&lt;br&gt;
With CSR, websites will face Search Engine Optimization(SEO) challenges. Since search engines generally rely on web crawlers, it's difficult for web crawlers to find the entire content of a particular page since only minimal HTML will be rendered initially and then the JavaScript will be rendered, which crawlers may not be able to process immediately, leading to bad SEO page rankings. &lt;br&gt;
Also, sharing these website links to social media can lead to problems. With CSR, when social media crawlers try to generate a preview for the website link, no content will be found since initially minimal HTML will be loaded. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Server-Side Rendering in Next.js&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Server-side rendering in Next.js means that the server generates HTML for each request and sends it to the browser(client).&lt;br&gt;
As the user requests a page, the Next.js server will fetch data(from the Database or from APIs) before rendering, and fully rendered HTML will be sent to the client, and the client will display the HTML page without any extra fetching or rendering.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8u1emwj9erxap0hj7uht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8u1emwj9erxap0hj7uht.png" alt="SSR in Next.js" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SEO with Next.js&lt;/strong&gt;&lt;br&gt;
Web Crawlers will get the fully rendered HTML for them to go through, which can lead to an easy understanding of the website, ultimately leading to better SEO page rankings.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setting up Next.js locally&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open terminal and run &lt;code&gt;create next-app@latest&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Yes&lt;/code&gt; for TypeScript, ESLint, TailwindCSS, &lt;code&gt;src&lt;/code&gt; directory, App Router
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0630qwbyiq2drsw7165.png" alt="create-next-app" width="800" height="291"&gt;
&lt;/li&gt;
&lt;li&gt;Once the dependencies are installed, you will see a success message as shown below
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35ytmt9f99b8e15hwj0v.png" alt="Success Message" width="800" height="184"&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;npm run dev&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open your favorite browser and enter &lt;code&gt;localhost:3000&lt;/code&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpr7fes5qp2cfrqxuj8p.png" alt="localhost:3000" width="800" height="503"&gt;
&lt;/li&gt;
&lt;li&gt;BINGO!!! You now have a Next.js project set up locally and ready for development!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;References - &lt;a href="https://nextjs.org/docs/app/getting-started/installation" rel="noopener noreferrer"&gt;https://nextjs.org/docs/app/getting-started/installation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>tailwindcss</category>
      <category>typescript</category>
      <category>react</category>
    </item>
  </channel>
</rss>
