13 reasons why you should use Nextjs
In this blog post I will explain 13 reasons why you should use Next.js.
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 thegetServerSide
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 a 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.
Satic 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.
Shameless Plug
Want to create your own blog? Well, I am creating a video series where you will learn about how to create a JAMstack blog with Nextjs and Chakra-UI.
Lessons
- Intro & Setup
- Build Homepage UI
- How our app will work
- MDX, MongoDB, Static Homepage
- Generate Static Blog Page
- Style Blog page with Chakra-UI and MDX-embed
- Build a real-time view counter
- Autocomplete search form with MongoDB Atlas Search Index
- Deploy application to Vercel
Demo
You can demo the website from here
Features
- Static Blog pages will make the website load faster.
- Blogs will have code blocks with syntax highlighting and many embed components like youtube videos, GitHub gist, Tweets, and so many other things.
- Autocomplete search feature for the blog posts.
- Real-time view counter and so on.
Please like and subscribe to Cules Coding. It motivates me to create more content like this.
That's it for this blog. I have tried to explain things simply. If you get stuck, you can ask me questions.
By the way, I am looking for a new opportunity in a company where I can provide great value with my skills. If you are a recruiter, looking for someone skilled in full-stack web development and passionate about revolutionizing the world, feel free to contact me. Also, I am open to talking about any freelance project. I am available on Upwork
Contacts
- Email: thatanjan@gmail.com
- LinkedIn: @thatanjan
- Portfolio: anjan
- Github: @thatanjan
- Instagram (personal): @thatanjan
- Twitter: @thatanjan
- Upwork: @thatanjan
Blogs you might want to read:
- Eslint, prettier setup with TypeScript and react
- What is Client-Side Rendering?
- What is Server Side Rendering?
- Everything you need to know about tree data structure
- 13 reasons why you should use Nextjs
- Beginners guide to quantum computers
Videos might you might want to watch: