<?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: kartikey rawat</title>
    <description>The latest articles on Forem by kartikey rawat (@carrycooldude).</description>
    <link>https://forem.com/carrycooldude</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%2F226956%2Fe0a16833-2530-4e74-99ea-a2fafe1eb15b.jpeg</url>
      <title>Forem: kartikey rawat</title>
      <link>https://forem.com/carrycooldude</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/carrycooldude"/>
    <language>en</language>
    <item>
      <title>Server Components: A New Feature in Next.js That You Need to Know About</title>
      <dc:creator>kartikey rawat</dc:creator>
      <pubDate>Sun, 30 Jul 2023 09:29:53 +0000</pubDate>
      <link>https://forem.com/carrycooldude/server-components-a-new-feature-in-nextjs-that-you-need-to-know-about-3pck</link>
      <guid>https://forem.com/carrycooldude/server-components-a-new-feature-in-nextjs-that-you-need-to-know-about-3pck</guid>
      <description>&lt;p&gt;&lt;strong&gt;What are Server Components in Next.js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Server Components are a new feature in Next.js that allow developers to write server-side code directly in their React components. This means that the components can be rendered on the server before being sent to the client, which can improve performance and SEO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do Server Components work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user requests a page that contains a Server Component, Next.js will first render the component on the server. This process involves parsing the component's code, resolving its dependencies, and fetching any data that the component needs. Once the component has been rendered, Next.js will send the rendered HTML to the client.&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%2Fls80xzad2mdasezc3ewv.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%2Fls80xzad2mdasezc3ewv.png" alt="Thinking in Server Component" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the benefits of using Server Components?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several benefits to using Server Components, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Improved performance:&lt;/strong&gt; Server Components can improve performance by rendering the components on the server before they are sent to the client. This can reduce the amount of JavaScript that needs to be downloaded by the client, which can improve the initial load time of the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better SEO:&lt;/strong&gt; Server Components can also improve SEO by rendering the components on the server. This means that the search engines will be able to see the rendered HTML, which can help your pages rank higher in search results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More flexibility:&lt;/strong&gt; Server Components give you more flexibility in how you build your applications. You can use them to move data fetching to the server, closer to your database. You can also use them to keep large dependencies that previously would impact the client JavaScript bundle size on the server, leading to improved performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to use Server and Client Components?
&lt;/h2&gt;

&lt;p&gt;To simplify the decision between Server and Client Components, we recommend using Server Components (default in the &lt;code&gt;app&lt;/code&gt; directory) until you have a use case for a Client Component.&lt;/p&gt;

&lt;p&gt;This table summarizes the different use cases for Server and Client Components:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What do you need to do?&lt;/th&gt;
&lt;th&gt;Server Component&lt;/th&gt;
&lt;th&gt;Client Component&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fetch data.&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access backend resources (directly)&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep sensitive information on the server (access tokens, API keys, etc)&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep large dependencies on the server / Reduce client-side JavaScript&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add interactivity and event listeners (&lt;code&gt;onClick()&lt;/code&gt;, &lt;code&gt;onChange()&lt;/code&gt;, etc)&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use State and Lifecycle Effects (&lt;code&gt;useState()&lt;/code&gt;, &lt;code&gt;useReducer()&lt;/code&gt;, &lt;code&gt;useEffect()&lt;/code&gt;, etc)&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use browser-only APIs&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use custom hooks that depend on state, effects, or browser-only APIs&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use &lt;a href="https://react.dev/reference/react/Component" rel="noopener noreferrer"&gt;React Class components&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;☒&lt;/td&gt;
&lt;td&gt;☑&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use Server Components in Next.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To use Server Components in Next.js, you need to add the &lt;code&gt;export default&lt;/code&gt; keyword to the top of your component file. You also need to add the &lt;code&gt;use server&lt;/code&gt; directive to the top of any asynchronous functions that you want to run on the server.&lt;/p&gt;

&lt;p&gt;Here is an example of a Server Component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ServerComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;This is a Server Component&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;The data from the API is: &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// This function will run on the server&lt;/span&gt;
&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Server Components are a powerful new feature in Next.js that can improve the performance, SEO, and flexibility of your applications. If you are looking for ways to improve your Next.js application, I encourage you to try using Server Components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Diagram of how Server Components work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a diagram of how Server Components work in Next.js:&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%2Fojpd6ejk5xweedc7pqva.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%2Fojpd6ejk5xweedc7pqva.png" alt="A React tree with server components (orange) and client components (blue)" width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The diagram shows that when a user requests a page that contains a Server Component, Next.js will first render the component on the server. This process involves parsing the component's code, resolving its dependencies, and fetching any data that the component needs. Once the component has been rendered, Next.js will send the rendered HTML to the client.&lt;/p&gt;

&lt;p&gt;The client will then receive the rendered HTML and display it in the browser. The client will not need to execute any JavaScript code to render the component, which can improve performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sharing fetch requests between Server Components
&lt;/h3&gt;

&lt;p&gt;When fetching data, you may want to share the result of a &lt;code&gt;fetch&lt;/code&gt; between a &lt;code&gt;page&lt;/code&gt; or &lt;code&gt;layout&lt;/code&gt; and some of its children components. This is an unnecessary coupling between the components and can lead to passing &lt;code&gt;props&lt;/code&gt; back and forth between components.&lt;/p&gt;

&lt;p&gt;Instead, we recommend colocating data fetching alongside the component that consumes the data. &lt;a href="https://dev.to/docs/app/building-your-application/data-fetching#automatic-fetch-request-deduping"&gt;&lt;code&gt;fetch&lt;/code&gt; requests are automatically deduped&lt;/a&gt; in Server Components, so each route segment can request exactly the data it needs without worrying about duplicate requests. Next.js will read the same value from the &lt;code&gt;fetch&lt;/code&gt; cache.&lt;/p&gt;

&lt;p&gt;I hope this blog has helped you understand Server Components in Next.js. If you have any questions, please feel free to leave a comment below.&lt;/p&gt;

&lt;p&gt;Credits-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/getting-started/react-essentials" rel="noopener noreferrer"&gt;NextJS Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.plasmic.app/blog/how-react-server-components-work" rel="noopener noreferrer"&gt;chungwu's blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>react</category>
    </item>
    <item>
      <title>Transcribe speech input to text on Azure Cloud</title>
      <dc:creator>kartikey rawat</dc:creator>
      <pubDate>Sun, 11 Apr 2021 17:01:07 +0000</pubDate>
      <link>https://forem.com/carrycooldude/transcribe-speech-input-to-text-on-azure-cloud-487l</link>
      <guid>https://forem.com/carrycooldude/transcribe-speech-input-to-text-on-azure-cloud-487l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The Speech-to-Text aspect of the Speech service transcribes audio streams into text. Your application can display this text to the user or act upon it as command input. You can use this service either with an SDK client library (for supported platforms and languages) or a representational state transfer (REST) API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of speech-to-text
&lt;/h2&gt;

&lt;p&gt;The Speech-to-text aspect of the Speech services, in Azure Cognitive Services, provides a real-time transcription of audio streams based on machine learning and artificial intelligence. The Speech services APIs allow developers to add end-to-end, real-time speech transcription to their applications or services.&lt;br&gt;
Speech services are designed to perform real-time speech-to-text for scenarios like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Translation of live presentations&lt;/li&gt;
&lt;li&gt;In-person or remote translated communications&lt;/li&gt;
&lt;li&gt;Customer support&lt;/li&gt;
&lt;li&gt;Business intelligence&lt;/li&gt;
&lt;li&gt;Media subtitling&lt;/li&gt;
&lt;li&gt;Multilingual AI interactions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a Speech Service
&lt;/h2&gt;

&lt;p&gt;Before you can begin performing your speech-to-text translation, you need to create an Azure Speech resource. You can do this by using the Azure portal, the Azure CLI, or the Cloud Shell. This exercise will use the Azure portal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to the Azure portal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select + Create a resource. In the Search the Marketplace box, type speech and press Enter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Results list, select Speech. In the Speech pane, select Create.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a unique name for your Speech Service resource.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select an appropriate subscription.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a location to host the resource. This is typically the region where the resource will be used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the Pricing tier, select a tier. The tiers may change but currently, you can selects F0 or S0. For testing, we selected F0.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new resource group (RG) named mslearn-speechapi to hold your resources. You can also choose an existing RG if you wish&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Create to create a subscription to the Speech Translation API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2F1xelkx8z2njkfs1tluq3.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%2F1xelkx8z2njkfs1tluq3.png" alt="image" width="331" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Hacktoberfest Journey</title>
      <dc:creator>kartikey rawat</dc:creator>
      <pubDate>Thu, 29 Oct 2020 12:07:48 +0000</pubDate>
      <link>https://forem.com/carrycooldude/my-hacktoberfest-journey-25d9</link>
      <guid>https://forem.com/carrycooldude/my-hacktoberfest-journey-25d9</guid>
      <description>&lt;h3&gt;
  
  
  [✨This is my first hacktoberfest and this gave me the inspiration to do contribution to Open Source✨]
&lt;/h3&gt;

&lt;h3&gt;
  
  
  I am Kartikey Rawat, student of Bhilai Institue of Technology, Durg. I am studying Computer Science and 3rd CSE Undergrad.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  I am completed my 4 Pull Request in Hacktoberfest and after making my first PR, I got goosebumps as I got the feeling to contribute in some big tech stacks but that it's fine
&lt;/h3&gt;

&lt;h3&gt;
  
  
  First Project is on Tensorflow.js Project where I just update the documentation and improve the model and after ones are the those which listed out in hacktoberfest label. This is the link to the project
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/hugozanini/realtime-semantic-segmentation/pull/4" rel="noopener noreferrer"&gt;https://github.com/hugozanini/realtime-semantic-segmentation/pull/4&lt;/a&gt; &lt;/p&gt;

</description>
      <category>hacktoberfest</category>
    </item>
  </channel>
</rss>
