<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sureka Raja on Medium]]></title>
        <description><![CDATA[Stories by Sureka Raja on Medium]]></description>
        <link>https://medium.com/@surekarajainfo?source=rss-73e5b1672b3a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cy-mKrAXRIDI1NYz</url>
            <title>Stories by Sureka Raja on Medium</title>
            <link>https://medium.com/@surekarajainfo?source=rss-73e5b1672b3a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:06:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@surekarajainfo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Top 10 features why Next JS is popular]]></title>
            <link>https://medium.com/@surekarajainfo/important-features-of-next-js-dd88d39e8ce8?source=rss-73e5b1672b3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd88d39e8ce8</guid>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Sureka Raja]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 15:48:50 GMT</pubDate>
            <atom:updated>2021-09-24T08:50:33.408Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Next JS is the React framework for production</blockquote><p>In simple words, Next JS is a full stack framework where it uses React for front-end and it supports API routes for backend.</p><p>Next JS is a pre-rendered React app in the client-side that users can view and interact with and consider as front-end. At the same time, it also does server-side rendering and API routes which can perform server-side code and access data in the database and can be considered as back-end</p><p>Next JS is used to build full feature rich production ready application as it supports routing, authentication, bundle optimization, API routes etc without any configuration or third party packages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*D2BCz6fPwof2HztpW287FA.png" /><figcaption>Next.js</figcaption></figure><p>Next JS follows conventions and opinions over configurations. It provides everything for the developer so that the developer can focus more on code than configuration.</p><p>Here are the important features of Next JS</p><h3>1. File based routing</h3><p>File based routing (page based routing mechanism) is the feature provided by Next JS inorder to not install any third party packages and avoid configurations. The files and folders created inside pages folder is associated with routes based on file and folder name. So we can create routes as we want by mix and matching the folder and file names.</p><p>This mechanism also provides support for <strong>dynamic pages</strong>.</p><p><strong>Catch all routing</strong> is possible where we can use same page for different url’s. This can be used for pages with optional query parameters or for filtering options. Example — ecommerce site with different filters routes to the same layout but the content will be different based on the filter.</p><p>In <strong>client side routing</strong>, <strong>navigating via link</strong> can be done by <strong>Link component</strong> and <strong>navigating programmatically</strong> can also be done with useRouter hook provided by Next JS. For example if onclick of link or button needs to route to another page the above features can be used.</p><blockquote>Routes without specific file in pages folder will show 404 page by default. Customization can also be done.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*0kwG1v0sDE1HQyXrhT8ivQ.png" /><figcaption>File based routing</figcaption></figure><h3>2. Pre-rendering</h3><p>Pre-rendering is the most powerful feature where the HTML for every pages in Next JS app are generated in advance with all the neccessary content. So if user requests for a page, server will serve the already generated HTML within milliseconds. This provides better performance. Next JS also contributes for SEO as the search engine finds easy to search for keywords when the HTML is fully generated by server and metadata are available for it to crawl and index in better rankings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BuQ-vjlQYOaQHqwWr4EQpg.png" /><figcaption>Pre-rendering</figcaption></figure><p>It has hybrid support of rendering with both static site generation(SSG) and server side rendering(SSR). We can also make use of client side rendering(CSR) along with SSG and SSR based on our application.</p><p><strong>Static site generation(SSG)</strong> can be done by exporting getStaticProps function in the pages. The HTML will be pre-rendered at the build time. If the page needs external data, the data will be fetched first and then the HTML will be generated at the build time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7cEeFLqXmP2x05tydR9qBg.png" /><figcaption>Static generation without data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNISO-IzxzMljRtw3bEVZw.png" /><figcaption>Static generation with data</figcaption></figure><p>But for each and every change in data we need to rebuild the server inorder to reflect the changes in browser. We can use SSG in Marketing and blogging sites as this sites require less changes.</p><p>This has disadvantages of build time and stale data.</p><p><strong>Build time</strong> will be proportional to the number of pages used in application. This can be reduced by using fallback key which provides the flexibility to generate few popular pages at the build time, other pages at the request time for the initial load and this newly generated pages will be tracked for the subsequent requests. But this is suitable only for applications that has 90% dynamic pages and 10% static pages not for applications with 10% dynamic pages and 90% static pages.</p><p><strong>Stale data </strong>issue<strong> </strong>can be fixed if the pages are regenerated for request after some time limit or for every request.</p><p>So here comes the <strong>Incremental static generation(ISR)</strong> to overcome the stale data disadvantage of static site generation to an extent. In ISR only when server gets request after the time limit given in revalidate key, the regeneration will be initiated and the new regenerated HTML will be served. We can use ISR in documentation and e-commerce sites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Xbguh52cGxnAlYtUZHGFw.png" /><figcaption>Incremental static generation</figcaption></figure><p>But if we need our application not to render stale data even for fraction of second then we need to use <strong>Server side rendering(SSR) </strong>where HTML will be generated in every request time. But this may slow down the application. We can use SSR for sites that cannot have stale data even for a second like news sites and other sensitive websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MLOE44CrBn1CDUgLWzta6g.png" /><figcaption>Sever side rendering</figcaption></figure><p>So we can also use <strong>Client side rendering(CSR) </strong>for applications that are behind login screen or highly user specific or SEO can be less important. Google crawlers improved the crawling for CSR but if the JS bundle size is too large then the crawler will crawl the empty HTML as it takes more time to load and execute JS, and then compile and mount the HTML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1sw_dW-JwfX17suS3e1UNg.png" /><figcaption>No pre-rendering</figcaption></figure><blockquote>It is possible to pre-render pages using SSG or SSR and can filter with client side data fetching using shallow routing.</blockquote><p><a href="https://swr.vercel.app/"><strong>Stale-while-revalidate(SWR)</strong></a> is the react hook library for data fetching created by Next JS team. This provides many features and is simpler to use instead of using useState and useEffect hooks for client side data fetching.</p><blockquote>It is always good to use SSG whenever possible instead of SSR or CSR.</blockquote><h3>3. API Routes</h3><p>Next JS has in-built support for API routes. We need to add files related to API routes in api folder so this will automatically create routes for API’s based on file and folder name. This is more similar to file based routing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOLbaYL0UrafTJjJF7hi9Q.jpeg" /><figcaption>API routes</figcaption></figure><h3>4. CSS modules</h3><p>Next JS provides extensive support for CSS.</p><p>a. <strong>Global</strong> css needs to be imported in _app.js file so this css will be available for every pages. The same thing applies for external css libraries like bootstrap etc.<br>b. <strong>Component</strong> specific css should be included in filename.module.css files. This is locally scoped. So it is possible to have same classname among different component specific css files. This will not collides with other component specific css files or global files. This component specific files need to be imported in specific components.<br>c. For <strong>SASS or SCSS</strong> css install sass package and include css in filename.module.scss or filename.module.sass. These files need to be imported in specific components.<br>d. <strong>Inline</strong> css can be used by using normal style attribute.<br>e. <strong>CSS frameworks</strong> like styled-component, tailwind, emotion etc can also be used in Next JS.</p><h3>5. Authentication</h3><p>Next JS has great support for <strong>client side authentication, server side authentication, API routes authentication</strong> and way to <strong>persist user data in any database</strong> of our choice. Routes like GET, POST, PATCH, DELETE, dynamic API routes and catch all routes are supported.</p><p>Authentication providers can also be used with Next JS.</p><p>Next JS team suggests to use <a href="https://next-auth.js.org/"><strong>Next-auth library</strong></a> for full featured authentication system with built-in providers (Google, Facebook, GitHub…), JWT, JWE, email/password, magic links and more.</p><h3>6. Development and production build system</h3><p>Next JS provides development and well optimized production build system so that we can focus more on code than on configuration. <br>Next JS also supports hot reloading.<br>For development server, even in static site generation(SSR) the server pre-renders HTML for every request as it is logical because when developing the app it is time consuming to rebuild the app for every change.</p><h3><strong>7. Image component</strong></h3><p>Image component is used for <strong>image size and format optimization</strong>. <br>All images are loaded in webp format in browsers and image size depends on width, height mentioned in image component and also device resolution instead of original image’s size. <br><strong>Lazy loading</strong> of images is also supported.<br>Image component has support for <strong>placeholder</strong> too so till the image loads placeholder will be displayed. This avoids blank space or loading indicator.</p><h3>8. Head component</h3><p>Head component is used for providing <strong>header with title and description</strong> about application as this tags are not be available by default. As crawler checks for header title and metadata with description, this head component results in better SEO rankings.</p><h3>9. Application Layout</h3><p>Application layout can be handled in single _app.js file where the wrapper component can be wrapped with any layout components like header or footer if needed. <br>Layout provided in _app.js is the same layout that will be applied for every pages in the application. If we don’t need the same layout for every page we have option to customize the layout.</p><h3>10. Typescript</h3><p>Typescript is the integrated feature of Next JS. Create empty tsconfig.json file and install typescript the configuration will be automatically updated in tsconfig.json. Now we are ready to use default types as well as custom types in our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ko6gkclNlKYn58-r03KSLg.png" /><figcaption>Default type provided by Next</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*933NtOAiUCaLsLNGUxJzCQ.png" /><figcaption>Custom type</figcaption></figure><p>In the above images, default types from Next JS like GetStaticProps, GetStaticPaths, GetServerSideProps NextApiRequest, NextApiResponseand custom type like Data are used.</p><h3>Other features</h3><p>a. <strong>Absolute imports and Alias paths</strong> can be applied by simple configuration in jsconfig.json or tsconfig.json.</p><p>b. <strong>Static HTML exports </strong>are used to cache static files in CDN or any places where server is no needed and at request it will serve the files almost instantly to the clients.</p><p>c.<strong> Preview mode</strong> can be used for applications that rely on CMS. When preview mode is enabled even with static site generation(SSR), the server generates the HTML for every request till the preview mode is disabled.</p><p>d. <strong>Redirections</strong> can be done for temporary and permanent redirects with simple configuration in next.config.js file.</p><p>e. <strong>Environmental variables</strong> are only available for node.js environment and not for browsers. env.local is the file used and is git ignored by default. If we need to use the environment variables for browsers we can use NEXT_PUBLIC as prefix to the environment variables.</p><p>Next JS becomes popular as it solved a problem that many web developers faced with web applications rendered on the client-side. It provides out-of-box solution for server-side rendering(SSR) of React components. When application depends on SSG, Gatsby can be considered. But if it rely on SSR, I don’t think that Next JS has any competition.</p><p>Reference — <a href="https://nextjs.org/docs">https://nextjs.org/docs</a></p><h3>Comments</h3><p><a href="https://www.blogger.com/">Powered by Blogger</a></p><p>Theme images by <a href="http://www.offset.com/photos/394244">Michael Elkan</a></p><p><a href="https://www.blogger.com/profile/11263680496475983567"><strong>SUREKA</strong></a><a href="https://www.blogger.com/profile/11263680496475983567">VISIT PROFILE</a></p><h3>Archive</h3><h3><a href="https://www.blogger.com/go/report-abuse">Report Abuse</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd88d39e8ce8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>