DEV Community

Cover image for 13 reasons why you should use Nextjs
Anjan Shomooder
Anjan Shomooder

Posted on

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
Enter fullscreen mode Exit fullscreen mode
  • 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:




Discussion (23)

Collapse
rammina profile image
Rammina

Great introduction as to what advantages Next.js offers. Nice cover image by the way!

Collapse
thatanjan profile image
Anjan Shomooder Author

Thank you so much

Collapse
ats1999 profile image
Rahul kumar

Do you know about ISR?

Collapse
rammina profile image
Rammina

I have heard of Incremental Static Regeneration in Next.js. I just recently learned Next.js, so I'm not good at it yet.

Thread Thread
ats1999 profile image
Rahul kumar

This is main dis advantage of nextjs, that we can not update the page generated by ISR using API.

Either we can not update or wait for revalidate to complete

Thread Thread
rammina profile image
Rammina

I see, I'm going to look into it. Thank you!

Thread Thread
ats1999 profile image
Rahul kumar

Please have a look at the website i have created with nextjs, reactjs, chakra-ui, MongoDB, dynamodb and express js

dsabyte.com

Thread Thread
whatthehanan profile image
Hanan Hamza

You can use SWR to re-validate ISR generated page. SWR takes in static data as an initialData prop as well. you can get the best of both worlds.

Thread Thread
ats1999 profile image
Rahul kumar

SWR is a client side data feaching library. It can not be used to rebuild the page generated by ISR.

Collapse
merri profile image
Vesa Piittinen

Astro is better.

Yes I know Astro provides no SSR, only SSG. But the fact remains Astro is better, and eventually NextJS can't match Astro.

Collapse
henrikvtcodes profile image
Henrik VT

They’re different tools for different purposes. Astro was built to ship zero JS by default, and will always have a speed advantage but it cannot match the versatility of Next.

Collapse
merri profile image
Vesa Piittinen

Next can't match the versatility of using any client-side tool, and the freedom provided by islands architecture from issues caused by other current React solutions requiring to take over the entire DOM. Always need to workaround that if you're aiming for no layout shifting, or if you need to provide a platform that works well for a growth hacking team. Many hours wasted fixing issues which should be no-issues.

Collapse
ats1999 profile image
Rahul kumar

Please have a look at the website i have created with nextjs, reactjs, chakra-ui, MongoDB, dynamodb and express js

dsabyte.com

Collapse
thatanjan profile image
Anjan Shomooder Author

Hey. Your website is very good. I really like it.

Collapse
ats1999 profile image
Rahul kumar

Hey, i am looking for help in this website. I have created a blog post for that dev.to/ats1999/is-discuss-useful-f...

I don't need any technical help, rather i want to know about a feature should be implemented in the website or not

Sorry for poor english writing skill.

Collapse
xlttj profile image
Axel Tietje

All this stuff can be done with Vue or Angular or Svelte, too. Choosing a library (like React) or a framework (like Angular) always depends on the project at hand.

„One does not simply choose a library only by reading the feature list“ – Boromir.

Collapse
declanpossnett profile image
Declan Possnett

This.

Collapse
miladtehrany profile image
Milad Tehrany

Thanks, it's beneficial

Collapse
hoangvanhoa1701 profile image
Hoàng Văn Hòa

Ohh... Nice the post. Thank you so much for the post!

Collapse
thatanjan profile image
Anjan Shomooder Author

It's my pleasure.

Collapse
ats1999 profile image
Rahul kumar

Do you know about ISR?

Collapse
dshung1997 profile image
Sy Hung Doan

A good read!

Collapse
filip_uzunovic profile image
Case09

I'll just leave this here.. svelte.dev/