Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 15, 2021 06:09 pm GMT

13 reasons why you should use Nextjs

Now, why should we use it? Simply because it solves our problems. So let's see the problems that Nextjs solves for us.

  • SEO: One of the most drawbacks of client-side rendering is poor SEO. Because in CSR you don't have any content on your HTML page. All content is rendered by the javascript. That's why search engines don't give you give search engine optimization. So, we need server side rendering. And Nextjs allow us to do that.

  • Server Side Rendering: Client side rendering has a bunch of problems like SEO, huge bundle size, slow initial load, and blank page flickering. Server side rendering doesn't have that problem. And we can use server side rendering with nextjs.

  • Static Site Generation: Suppose you have a blogging website. In this type of website the content hardly changes after it gets deployed. So you don't need to fetch any data from the client or server side. Everything is present on the html and CSS. So the browser only needs to parse them and maybe a little bit javascript. This type of website we called static sites. They are super fast because they have fewer tasks to complete. With Nextjs, we can generate out static html on build time and we don't have to worry about it anymore.

  • Client Side Rendering: Yes, you can also do Client side rendering in nextjs. If you want to have single page application that doesn't refresh, well you can have it here. You combine the 3(CSR, SSR, SSG) rendering systems in Nextjs. You provide your static HTML or fetch data from getStaticProps which will be treated as static html. So you can have SEO. Then you fetch the necessary server side data from the getServerSide function. And lastly, you can use any client side data fetching method. And that's how you can have a combination of 3rendering systems.

I have already made video about client and server side rendering. You can check them out.

  • Image Optimization: Image is very important for our website. It can make the user experience so much better and also it can make our website super slow. So we need to optimize our images. And Nextjs here is to help us. With Nextjs Image component, we don't have to worry about optimization. It will do all the work for us. It can make our:

    • Image size is smaller while keeping the quality good.
    • Lazy load our images.
    • Responsive images based on the screen width.
  • Built-in Routing: It has a built-in routing system. You don't need to install any external package. It gives you all of the features out of the box.

  • Built-in CSS Support: With Nextjs you can:

    • directly import your css files.
    • import styles from node_modules directory.
    • use component-level CSS with CSS Modules.
    • Use any existing CSS-IN-JS solution.
    • Nextjs support Styled-jsx out of the box.

code with styled-jsx:

function HelloWorld() {    return (        <div>            Hello world            <p>scoped!</p>            <style jsx>{`                p {                    color: blue;                }                div {                    background: red;                }                @media (max-width: 600px) {                    div {                        background: blue;                    }                }            `}</style>            <style global jsx>{`                body {                    background: black;                }            `}</style>        </div>    )}export default HelloWorld
  • Api Routes: So you need a back-end server for your website. But the work is not too much. Setting up a server for a small amount of work is too much work. Again Nextjs comes to the rescue. It has a feature called API routes. It will allow you to build your API. You can not only implement REST but also Graphql.

  • Internationalized Routing: Nextjs has built-in support for internationalized (i18n) routing. Let me explain. Suppose you have a website in English and another language. If someone visits your website from Bangladesh, then you want your website language to be in Bengali. If someone visits Korea, then you want it to be Korean. I hope you are getting my point.

  • Code Splitting: Nextjs has Code splitting feature out of the box. If you don't know what it is then check out this blog ---> What is code splitting? by me. It simply splits the code into separate bundles to make the load faster.

  • Static Assets: It has a directory called Public where you can store all of your static files like SVG, image, video, etc.

  • File System Routing: It has a file system routing. There is a pages directory where you put all of your page files. Like you are storing HTML files. That makes things easy to handle.

  • Highly Configurable: If you have used create-react-app, then that you can't change the config. You have to either eject the project or apply some methods which are hard to do. But if you know webpack, then with nextjs you can configure your application with a single config file.

This is why you should use Nextjs. Nextjs is the most popular framework for React because of its awesome features. And there are more things to explore.

So, if you are using nextjs, why are you using it? And if you haven't tried it, then which of its feature is more interesting to you? Are you going to try it?

Please put your answers in the comment box. I would love to hear from you.

Shameless Plug

I have made a video about how to build a carousel postcard with React, Material-UI, and Swiper.js.
If you are interested you can check the video.

You can also demo the application form here

Screenshot of Insta Carousel

Please like and subscribe to Cules Coding. It motivates me to create more content like this.

If you have any questions, please comment down below.
You can reach out to me on social media as @thatanjan.
Stay safe. Goodbye.

About me

Why do I do what I do?

The Internet has revolutionized our life. I want to make the internet more beautiful and useful.

What do I do?

I ended up being a full-stack software engineer.

What can I do?

I can develop complex full-stack web applications like social media applications or e-commerce sites.

What have I done?

I have developed a social media application called Confession. The goal of this application is to help people overcome their imposter syndrome by sharing our failure stories.
Alt Text

I also love to share my knowledge. So, I run a youtube channel called Cules Coding where I teach people full-stack web development, data structure algorithms, and many more. So, Subscribe to Cules Coding so that you don't miss the cool stuff.

Want to work with me?

I am looking for a team where I can show my ambition and passion and produce great value for them.
Contact me through my email or any social media as @thatanjan. I would be happy to have a touch with you.

Contacts

Blogs you might want to read:

Videos might you might want to watch:





Original Link: https://dev.to/thatanjan/13-reasons-why-you-should-use-nextjs-2d40

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To