What is Next.js?

Next.js is becoming more and more popular recently. I want to explain exactly why and what does it do.

They call themselves "The React Framework for Production".

So, in a way, they convert React from a library to a framework.

Let's explain how they do it 🧵 What is Next.js?
⭐ Pre-rendering.

Next generates HTML for each page in advance, instead of doing it client-side.

This results in better performance and SEO.

There are two forms of pre-rendering.
- Static Generation (SSG). The HTML is generated at build time and it can be reused.

You can generate static pages with data, which can be fetched at build time. This is used for e-commerce sites, blogs, documentation, etc.
- Server-side rendering (SSR). The HTML is generated on each request.

This is slower than SSG, and it should only be used if you have no other option.
⭐ Image optimization.

Next has an Image component that automatically resizes, optimizes, and serves images in formats like WebP when the browser supports it.

They also avoid Layout shift, this happens when you are reading something, and suddenly the text moves on the page.
⭐ Fast Refresh.

This creates a better developer experience, every time you make a change in your project, you'll see the edit live without having to refresh the page, and, most importantly, without losing the state.

I can't express how good this is.
⭐ Routing.

In React, you need to install a package like react-router for your routes, in Next, you only need to create your js file inside your pages folder.

And, with the Link component Next provides, every page that's linked is prefetched when the original page loads.
⭐ API Routes.

You can build your own API with Next.js. This is serverless so it comes with some downsides, but for most projects, it's perfect.

It has a syntax really similar to Express so if you know that, it should pretty easy to pick up.
⭐ Easy authentication.

With Next, it's really easy to add authentication with a library they have created.

You can learn more about it here: next-auth.js.org
⭐ Hundreds of official templates.

When creating a Next project, you never have to start from scratch. Do you want a project with Tailwind? Redux? Auth? Typescript?

There's a template for you, this website is my go-to for easy search:

nextexamples.vercel.app
For these and other multiple reasons, lately, I've been using Next.js for all my projects instead of React.

I believe the developer experience is much better and I can create projects in a much faster way.
If you enjoy this thread and you would like to see more like this. A follow will be much appreciated (@nachoiacovino).

This thread was inspired by one of my multiple conversations with my followers, so feel free to reach out and talk with me about anything, DMs are open 😊

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Nacho Iacovino ⚡

Nacho Iacovino ⚡ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @nachoiacovino

24 Feb
CSS fundamentals before learning Tailwind.

Some people believe that you need to be a CSS master before starting learning Tailwind, and that couldn't be further from the truth.

You should know some fundamentals, and I want to tell you exactly which ones.

Let's begin 🧵 CSS fundamentals before learning Tailwind
background properties.

This is used to give properties to the background of an element, it could be any element.

These are the main ones you should know about: .box {   background-color: red;   background-image: url('som
margin, padding and border properties.

The first attached image is a visual representation of how this works.

- padding is the internal margin.
- border is the border of the box.
- margin is the margin outside the box.

You can use top/right/bottom/left or the shorthand. .box {   /* margin and padding works the same */   margin-to
Read 12 tweets
19 Feb
I recreated the Stack Overflow login page with Tailwind CSS.

It's not perfect but I'm happy with the end result.

What differences can you spot? 👀

What do you think? What should I recreate next? CloneOriginal
Let's a poll! Which one do you think is the real one?
If you would like to learn how to use Tailwind and how to create clones like this, you would love the course I'm building.

Sign up to stay updated!

windcourse.co
Read 4 tweets
18 Feb
How to deploy (upload) your project to the Internet.

For free.

One of the most important things when creating a website/portfolio is putting it online. People need to see what you create.

I'm gonna explain the easiest way to do it.

You are gonna love it.

Let's begin 🧵 How to upload your project ...
We are gonna use @vercel.

First, go to vercel.com/signup and create an account. This is completely free.
We need two more things, Node.js installed and a code editor, I'm using @code.

You can download Node here: nodejs.org/en/ (Recommended version)

And VSCode from here: code.visualstudio.com
Read 10 tweets
15 Feb
JavaScript fundamentals before learning React.

Some people believe that you need to be a JavaScript master before starting learning React, and that couldn't be further from the truth.

You should know some fundamentals, and I want to tell you exactly which ones.

Let's begin 🧵 JavaScript fundamentals before learning React.
let and const.

This is the ES6 way of assigning variables, it replaces "var".

"let" is for variables that are gonna be reassigned in the future.

"const" is for variables that are not gonna change, you define them and you use them, but they have a "constant" value.
imports and exports.

A big part of React is reusability. You create a component (like a button), export it, and then import it on your other components without having to write it out again. /* components/Button.js */ const Button = () => {   return <
Read 11 tweets
8 Feb
Let's build your first App in React.

React is the most popular JavaScript library to build websites nowadays.

If you have never tried it, I want to show you today how to create a very basic counter app that will teach you the fundamentals.

Let's begin! 🧵
First step!

Having Node.js installed. If you haven't, follow this link and download and install the recommended version.

nodejs.org/en/
Now we are gonna open a terminal (cmd, Bash, PowerShell...) in the folder that we want to create our project.

Write this command:

npx create-react-app my-first-app

npx will download CRA latest version and delete it when it's done. "my-first-app" is the name of our app.
Read 15 tweets
25 Jan
How to optimize images for web ⚡

One of the most common mistakes I noticed by reviewing websites is that many people don't optimize their images.

Let's take a look and why should you optimize them and how you can do it efficiently.

Let's start! 🧵
Images are one the most important parts of a website. But unoptimized images file's size is often very big.

One simple image could be 2MB, imagine if you have 10 of them. Now imagine someone with really slow internet trying to access your website. It will take forever.
Let's put an example of how we can optimize it.

This is a screenshot of my new portfolio (still under construction), when I take the screenshot, it's a .png file and the size is 539KB. Image
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!