<?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: Pushkar Borkar</title>
    <description>The latest articles on Forem by Pushkar Borkar (@pushkarborkar).</description>
    <link>https://forem.com/pushkarborkar</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%2F888157%2F8d2c1ade-69cd-4ea0-8e34-80b20b1dcacf.jpg</url>
      <title>Forem: Pushkar Borkar</title>
      <link>https://forem.com/pushkarborkar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pushkarborkar"/>
    <language>en</language>
    <item>
      <title>Rendering Strategies in Next.js</title>
      <dc:creator>Pushkar Borkar</dc:creator>
      <pubDate>Mon, 25 Jul 2022 11:41:15 +0000</pubDate>
      <link>https://forem.com/pushkarborkar/rendering-strategies-in-nextjs-2o88</link>
      <guid>https://forem.com/pushkarborkar/rendering-strategies-in-nextjs-2o88</guid>
      <description>&lt;p&gt;Next.js is a framework of recent times. It is built on the shoulders of its predecessors and hence it packs all the best features of them. Due to this Next.js comes with choice of rendering the content. You can either opt in to render a blank html and fill in the components dynamically with javascript, or you can make the server send you packages of content pre-built on the server, ore even better you can ask for a cached copy of the content from a CDN. And the best part is you don't have to subscribe to a particular strategy for the whole application, you can customise and use the strategy best for that page/route for each page/route separately.&lt;/p&gt;

&lt;p&gt;In this blogpost I will try to compile my understanding of these various rendering strategies, when is it best to use them and how to implement each one in Next.js. So let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSR: Client Side Rendering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/jUhkz8bRXfFqpwP34k/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/jUhkz8bRXfFqpwP34k/giphy.gif" alt="JavaScript Painting" width="960" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CSR or Client Side Rendering is exactly what it says, the html shell of an application is sent from the server to the client and then the javascript fill int the content as per the route. By default* the Next app uses client side rendering to render the content on the site.&lt;/p&gt;

&lt;p&gt;It is ideal to use CSR when the data on the site is purely dynamic i.e. there is nothing certain about what the data will be and the data is being filed dynamically. Some use cases for these will be a payment portal for an e-commerce store, a chat window in a chat app, etc.&lt;/p&gt;

&lt;p&gt;You don't have to do anything different than writing normal React components in Next to use CSR, as I said Next uses CSR by default*.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function ReactComponent() {

  useEffect(() =&amp;gt; {
    // fetch data here
  }, [])

  return (
    // render the component
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PROS&lt;/strong&gt;: Your pages are dynamic and no recurrent server calls are made.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONS&lt;/strong&gt;: If the data get huge there will likely be lags and loading states (Bad UX) and there is nothing for the browser bots to read (Bad SEO).&lt;/p&gt;

&lt;h2&gt;
  
  
  SSR: Server Side Rendering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/fepKnAxq8tjIGTcxny/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/fepKnAxq8tjIGTcxny/giphy.gif" alt="Browser bots Happy" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you use SSR or Server Side Rendering, Next get the data require for the path on the server itself and builds the page for that route on the server and then sends the prebuilt page to the client and hence, providing page fully loaded with content from the very start.&lt;/p&gt;

&lt;p&gt;SSR is ideally used where the you want the used to not notice any lag in the page loading and the data coming in to the page hence improving the user experience. It can also be used where the the there is less need of the page being more purely dynamic and more need of improving the SEO of the site.&lt;/p&gt;

&lt;p&gt;In Next.js you can simply make a page use SSR rendering strategy by adding in a method called &lt;code&gt;getServerSideProps()&lt;/code&gt; and fetching all the dependent data in this method and export props from it and consuming the props in the React component for the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getServerSideProps() {

  // fetch data here

  return {
    props: {
      data,
    }
  }
}

export function ReactComponent(props) {

  return (
    // render the component
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PROS&lt;/strong&gt;: Better SEO, Better User Experience&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONS&lt;/strong&gt;: More server calls&lt;/p&gt;

&lt;h2&gt;
  
  
  SSG: Static Site Generation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/2dbnhlCH2JhwdI2gHp/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/2dbnhlCH2JhwdI2gHp/giphy.gif" alt="CDN" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the best (objectively 😁), SSG or Static Site Generation is when the pages for the routes are built and stored to a CDN, so whenever the route is hit the page is server readily built from the CDN. (Just WOW)&lt;/p&gt;

&lt;p&gt;This strategy is best for the cases where the data on the page is not changes frequently, such as blogs and landing pages. You can SSG for changing data too but it is not ideal.&lt;/p&gt;

&lt;p&gt;In Next.js to implement a page/route as statically generated page, you just need to add a additional method provided by Next called &lt;code&gt;getStaticProps()&lt;/code&gt;, fetch data here, export it as props and then consume it in the React component for the page/route.&lt;/p&gt;

&lt;p&gt;The tricky part with this is when you need to SSG dynamic routes. What you need to do in these situations is add another method provided by next called &lt;code&gt;getStaticPaths()&lt;/code&gt;, return all the possible sub-routes from here and consume these as the ids in the &lt;code&gt;getStaticProps()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getStaticPaths() {

  // get data here

  return {
    params: {
      id: *ID for this page*,
    }
  }
}

export async function getStaticProps() {

  // fetch data here

  return {
    props: {
      data,
    }
  }
}

export function ReactComponent(props) {

  return (
    // render the component
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PROS&lt;/strong&gt;: SuperFast, No Server calls, directly server from CDN&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONS&lt;/strong&gt;: Not good with frequently changing data&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;All these rendering strategies are different tools and each of these tools is suited for different task and accomplish different things. The great thing is in Next.js you can configure for each page/route to which strategy to use for that particular page.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;* Well Next.js don't use CSR all the way. It will serve server render pages for the path and then CSR takes over.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Unraveling the Components of a Next.js App</title>
      <dc:creator>Pushkar Borkar</dc:creator>
      <pubDate>Thu, 07 Jul 2022 21:19:44 +0000</pubDate>
      <link>https://forem.com/pushkarborkar/unraveling-the-components-of-a-nextjs-app-3ope</link>
      <guid>https://forem.com/pushkarborkar/unraveling-the-components-of-a-nextjs-app-3ope</guid>
      <description>&lt;p&gt;When I started writing code in React, I didn't bothered to figure out what do the boilerplate and configuration files do. That meant I was writing code that works great but I was still feeling like an imposter. I took me long to get over that. So, while starting to learn Next.js, that was the first learning I did. This blog is part of my current running challenge &lt;em&gt;#30DaysOfNext&lt;/em&gt; (follow the challenge &lt;a href="https://twitter.com/PushkarBorkar"&gt;@PushkarBorkar&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, pull up your pants 😁 and type &lt;code&gt;npx create-next-app&lt;/code&gt; in your terminal and let's get started.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview of the Folder Structure
&lt;/h3&gt;

&lt;p&gt;When you first run the &lt;code&gt;create-next-app&lt;/code&gt; command, Next.js builds you a basic boilerplate Next App. Congratulations 🎉 you successfully built your very first Next App 😎. (&lt;em&gt;You can load up localhost:3000 to see it deployed there.&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;The file tree for your app will have a &lt;code&gt;/pages&lt;/code&gt; folder, &lt;code&gt;/public&lt;/code&gt; folder, &lt;code&gt;/styles&lt;/code&gt; folder and a bunch of config files. In this post we will discuss each of the folders and config files in detail.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uHOICRSs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dphmemwwv9axbl1aldsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uHOICRSs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dphmemwwv9axbl1aldsp.png" alt="Next.js App File tree" width="520" height="798"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pages and Components
&lt;/h3&gt;

&lt;p&gt;The first folder you would see is the &lt;code&gt;/pages&lt;/code&gt; folder. In Next.js this folder is mapped to routes on the app out of the box. Woah! That means that to add a new route in your app you just have to add a React Component(&lt;code&gt;.js&lt;/code&gt;/&lt;code&gt;.ts&lt;/code&gt; OR &lt;code&gt;.jsx&lt;/code&gt;/&lt;code&gt;.tsx&lt;/code&gt; file) in this folder and Next.js will create a route with the name of file. By convention all the files in this folder must follow camel-case naming. Next.js by default pre-renders all the page in the pages folder (&lt;em&gt;Better for SEO&lt;/em&gt; 💪), although you can opt which rendering strategy to use to pre-render the components SSR or SSG.&lt;br&gt;
&lt;em&gt;Blog on Rendering Strategy coming soon&lt;/em&gt; 🚀&lt;/p&gt;

&lt;p&gt;By Default there will be two files, namely &lt;code&gt;index.tsx&lt;/code&gt; and &lt;code&gt;_app.tsx&lt;/code&gt; and an &lt;code&gt;/api&lt;/code&gt; folder added to this folder. These have special meaning attached to them. Let's discuss them one-by-one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CFf9zCkg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18s95xdzap4aw55bjb22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CFf9zCkg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18s95xdzap4aw55bjb22.png" alt="Pages Folder" width="520" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;

&lt;p&gt;This files points to the base URL &lt;code&gt;/&lt;/code&gt; of your app. This will give you an idea of how a React Component for a URL route must be structured in a Next.js App. Every page component is of type &lt;code&gt;NextPage&lt;/code&gt;. So, Everything that you see currently on the localhost:3000 is rendered from here.&lt;/p&gt;

&lt;h4&gt;
  
  
  _app.js
&lt;/h4&gt;

&lt;p&gt;This is a special component. This file has the App component in it. App Component utilises the &lt;code&gt;&amp;lt;Component/&amp;gt;&lt;/code&gt; provided by Next.js to initialise all the pages. Additionally, this App Components can be customised to UI element persistent to the view i.e. visible on every page like a Navbar or a Footer. Also, this is where you will save a state that you want to be consistent on all the pages. &lt;/p&gt;

&lt;h4&gt;
  
  
  APIs
&lt;/h4&gt;

&lt;p&gt;With Next.js you can serve APIs from the same endpoint as that of you frontend. For adding API paths to the app you will just have to add files with the names that you want of the paths of the API to be. For example, if you want a &lt;code&gt;/posts&lt;/code&gt; path for the api then you just need to add a file named &lt;code&gt;posts.ts&lt;/code&gt; in the &lt;code&gt;/api&lt;/code&gt; folder and Voila! you can fetch data from the &lt;code&gt;localhost:3000/api/posts&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; All the apis paths will be in &lt;code&gt;/api/&amp;lt;filename&amp;gt;&lt;/code&gt; format.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Routing
&lt;/h4&gt;

&lt;p&gt;Routing is a handled in a very interesting way in Next.js Apps. As discussed above all the files in the pages folder points to separate paths same as the file name. But you can also nest paths by making a folder in the &lt;code&gt;/pages&lt;/code&gt; folder and adding files into that folder. For Example if you want to show friends of a user as &lt;code&gt;/user/friends&lt;/code&gt;, no problems, just add a &lt;code&gt;/user&lt;/code&gt; folder in the &lt;code&gt;/pages&lt;/code&gt; folder and add a friends component in the &lt;code&gt;/user&lt;/code&gt; folder. It's as simple as that.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;There is yet another very interesting topic under routing Dynamic Routing, I will save that for future posts&lt;/em&gt; 😁&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It is better to keep only the main components in the &lt;code&gt;/pages&lt;/code&gt; folder and refractor the helper components into a separate &lt;code&gt;/components&lt;/code&gt; folder under the root.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TWEtDyCu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/525jt6ui64s5wc6wv9bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TWEtDyCu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/525jt6ui64s5wc6wv9bi.png" alt="Components" width="338" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Public
&lt;/h3&gt;

&lt;p&gt;The second folder is the &lt;code&gt;/public&lt;/code&gt; folder. This is similar to public folder to React. You can access all the files in this folder straight from the browser by just typing file names after the base URL (&lt;em&gt;go ahead and try accessing the &lt;code&gt;favicon.ico&lt;/code&gt; file in the browser&lt;/em&gt;). Due to this fact, all the assets that the browser need like the logos and the favicons are stored in this folder. Also due to the same, you must be very careful of what you put in the &lt;code&gt;/public&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DEhO1Ps0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g76kp90w3sz9xgfep1vr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DEhO1Ps0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g76kp90w3sz9xgfep1vr.png" alt="Public Folder" width="520" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Styles
&lt;/h3&gt;

&lt;p&gt;The final folder is the &lt;code&gt;/styles&lt;/code&gt; folder. As the name suggests this folder contains the styles for the app. You are provided with built in Sass support in Next.js. But there are some conventions that are followed in a Next App for the naming of stylesheets. There are two types of stylesheets in Next.js namely,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Global Stylesheets&lt;/strong&gt;: These files are named regularly as &lt;code&gt;&amp;lt;filename&amp;gt;.css&lt;/code&gt;. You can only import these files in the &lt;code&gt;_app.tsx&lt;/code&gt; component and no other component file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Module Stylesheets&lt;/strong&gt;: These files are for more broader use they can be imported in any component. Naming convention for these is you need to add .module in their name. So the name of these files are in &lt;code&gt;&amp;lt;filename&amp;gt;.module.css&lt;/code&gt; format.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u0Jq8Xds--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdne0rrvx8ieogtnfvcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u0Jq8Xds--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdne0rrvx8ieogtnfvcu.png" alt="Styles Folder" width="520" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Config Files
&lt;/h3&gt;

&lt;p&gt;Apart from these folders there are config files in the file tree. Most of the times you will see the following files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.eslintrc.json&lt;/code&gt;: Config for ESLint&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;next-env.d.ts&lt;/code&gt;: This is a file defining various types in next. &lt;u&gt;This file must not be changed&lt;/u&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;next.config.js&lt;/code&gt;: This is the Next.js Config file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tsconfig.json&lt;/code&gt;: These are configurations for the Typescript Compiler (by default SWC but if you add &lt;code&gt;.babelrc&lt;/code&gt; file then it switches to Babel)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;package.json&lt;/code&gt;: This has all the app data and data about npm dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D9URYWiB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlqv51i67vgd618ruq8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D9URYWiB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlqv51i67vgd618ruq8r.png" alt="Config Files" width="464" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Out of all these &lt;code&gt;next.config.js&lt;/code&gt; and &lt;code&gt;tsconfig.json&lt;/code&gt; are the most interesting ones. So, lets discuss them further.&lt;/p&gt;

&lt;h4&gt;
  
  
  next.config.js
&lt;/h4&gt;

&lt;p&gt;This is the file that has all the Next.js configurations. It is usually a ES5 Module with various config key-value pairs. There are many configuration, but I will discuss a few here,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;headers:&lt;/strong&gt; you can set custom header for the app in here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;basePath:&lt;/strong&gt; you can set a custom base URL using this config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;reactStrictMode:&lt;/strong&gt; it is a boolean to toggle the Strict mode on/off&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;staticPageGenerationTimeout:&lt;/strong&gt; This is the time amount in seconds to wait before declaring static render failed.
You can read about all the configuration available &lt;a href="https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/constants.ts#L1-L5"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NtsqEepY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaaosev8ehsmysqmcd40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NtsqEepY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaaosev8ehsmysqmcd40.png" alt="Next Config" width="880" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  tsconfig.json
&lt;/h4&gt;

&lt;p&gt;This is the configuration for the Typescript Compiler. I will discuss some frequently used attributes of the config here,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;target:&lt;/strong&gt; this is the flavour of javascript that the typescript is compiled to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;noEmit:&lt;/strong&gt; when false create &lt;code&gt;.d.ts&lt;/code&gt; files for each TS file which has only types for the file&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;include:&lt;/strong&gt; which files to include for type checking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;exclude:&lt;/strong&gt; which files to not bother for type checking.
You can check all other available configs &lt;a href="//typescriptlang.org/tsconfig"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rjk138Si--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20o4ul77nwh2j7wes501.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rjk138Si--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20o4ul77nwh2j7wes501.png" alt="TS Config" width="880" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, now you have the foundational idea to how the Next.js App is structured and what does each and every part of the App do. Now we can go about making wonderful Apps with Next.js without feeling like imposters. 😇&lt;br&gt;
I'm learning Next.js for next 30 days straight (&lt;em&gt;#30DaysOfNext&lt;/em&gt;), do join me &lt;a href="https://twitter.com/PushkarBorkar"&gt;@PushkarBorkar&lt;/a&gt; ✌️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>discuss</category>
      <category>devjournal</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Exciting World of Next.js</title>
      <dc:creator>Pushkar Borkar</dc:creator>
      <pubDate>Wed, 06 Jul 2022 20:42:57 +0000</pubDate>
      <link>https://forem.com/pushkarborkar/exciting-world-of-nextjs-194k</link>
      <guid>https://forem.com/pushkarborkar/exciting-world-of-nextjs-194k</guid>
      <description>&lt;p&gt;Since the day I first heard of the next big thing, Next.js 😉 I was drawn to it. I have been reading about the workings of Next.js and more I learn about it, the more I am amused. So, I started a new challenge &lt;em&gt;#30DaysOfNext&lt;/em&gt; (updates on the challenge on my twitter - &lt;a href="https://twitter.com/PushkarBorkar"&gt;@PushkarBorkar&lt;/a&gt;). With all that said, let me introduce you to the &lt;em&gt;Exciting World of Next.js&lt;/em&gt;! 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Next.js exactly? 🤔
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Next.js is a flexible &lt;strong&gt;React framework&lt;/strong&gt; that gives you building blocks to create fast &lt;strong&gt;web applications&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, Next.js is a framework built on React. What does that mean? Next.js embraces React for what it does best, UI Rendering and augments it with tools for the other features like Routing, Data Fetching, Different Rendering Methods(very exciting topic), and much more.&lt;/p&gt;

&lt;p&gt;Next.js has a compiler made using &lt;a href="https://swc.rs/"&gt;SWC(Speedy Web Compiler)&lt;/a&gt;, a platform made in Rust which a low level language. It complies the code written in JSX and Modern TS/JS into code supported by all the browsers. Due to the fact that this is made in Rust, it way faster that the babel. 💪&lt;/p&gt;

&lt;h3&gt;
  
  
  Perks of Next.js for Devs 🧑‍💻
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ydrBIn30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crgj9k6t7yy1w3yymtwl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ydrBIn30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crgj9k6t7yy1w3yymtwl.jpeg" alt="Happy Dev" width="880" height="587"&gt;&lt;/a&gt;&lt;br&gt;
Next.js comes built-in with TypeScript and Linting using ESLint. It has a cool feature named &lt;a href="https://nextjs.org/docs/basic-features/fast-refresh"&gt;Fast Refresh&lt;/a&gt;, which changes the UI instantaneously on change of React code without even loosing state 😳.&lt;/p&gt;

&lt;p&gt;If you want to make new routes, no problem, just add a component in the &lt;code&gt;/pages&lt;/code&gt; directory and the route with the name of the file will render the component automatically 🤯&lt;/p&gt;

&lt;p&gt;You as a developer can choose how to render a components, do you want to render it server side and them serve to the client, or do you want to generate content on the client side. You can even cache a static site and distribute it from a CDN. And the best part is you can opt in for different styles of rendering and per-page-basis(different rendering method for different page) in the same App.&lt;br&gt;
&lt;em&gt;Rendering in Next.js is a very interesting topic I will cover that in the next blog&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Smooth End-user Experience with Next.js
&lt;/h3&gt;

&lt;p&gt;While making the code production ready Next.js optimises the code by performing the following steps,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compiling&lt;/strong&gt;: converts all the JSX and Modern TS/JS files into more accessible code for the browsers &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minifying&lt;/strong&gt;: removes all the indents, comments and non-essential elements in the compiled code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bundling&lt;/strong&gt;: bundles all the various components within the app and from the dependencies into a optimised bundles for browsers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Splitting&lt;/strong&gt;: splits the bundles according to various pages which are nothing but various paths in the app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the help of these steps Next.js is able to do some magical things. For Example, it pre-renders all the end-points that the links in the currently rendered page points to and caches them, so when a link is clicked the page is fully rendered and is served instantaneously.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is Next.js Better?
&lt;/h3&gt;

&lt;p&gt;Next.js was first introduced in October of 2016. It has been built upon the shoulders of the tech from last two decades. It brings the best of every phase of the web.&lt;br&gt;
It has the composability of Client Side Rendering, It has the dexterity of the Server Side Rendering and the great user experience for both Developers and End-Users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing Thoughts
&lt;/h3&gt;

&lt;p&gt;Next.js is a remarkable milestone in the journey of web. It is performant, has great dev experience and a great community.&lt;br&gt;
I am planning on learning this wonderful framework for the next straight for next 30 days (&lt;em&gt;#30DaysOfNext&lt;/em&gt;). You can learn with me, I will be sharing my DevLogs in the form of blogs and tweets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/docs/getting-started"&gt;The Official Docs for Next.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>motivation</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
