Lang
Blog

Next.js 13 is Here — What’s New?

ByKhushi Maheshwari
December 6th . 5 min read
NextJS 13

The origin of next.js is when we wanted to create dynamic server-rendered sites. It is a react framework that helps teams to build ambitious, complex applications. But being dynamic has always come with a lot of limits.

With Next.js 13, React has become even easier to use. This new version promises to make development faster and more efficient.

It comes with a number of new features and updates, including Hot Module Replacement for server rendering, performance enhancements, and support for TypeScript 3.0. If you’re looking to learn or use React in your next project, Next.js is definitely worth checking out.

An upgraded version of next js i.e., Next JS 13 allows developers to make “dynamic without limits” applications through innovative features, many of which are still in alpha or beta.

Updating the versions directly relates to upgrading yourself. You can easily upgrade next js version by using the command -

npm i next@latest react@latest react-dom@latest eslint-config-next@latest

Now, as the dust slowly settles, we can go through what’s new in Next.js 13.

app/ Directory in Next.js 13 (In Beta)

The most beneficial feature of Next.js is our file-system router. It even makes it a bit easier to create routes by dropping a file inside a folder. Configurations for each route are no more required.

With the introduction of the app/ directory (beta), there is a lot of improvement in routing and layout experience. Let’s see how ➖

  • Layouts: Easily share UI between routes while preserving state and avoiding expensive re-renders.
  • Streaming: Display instant loading states and stream in units of UI as they are rendered.
  • Server Components: Making server-first the default for the most dynamic applications.
  • Support for Data Fetching: async Server Components and extended fetch API enables component-level fetching.

While you don’t need to use the app/ directory when upgrading to Next.js 13, the app/ directory can coexist with the existing pages directory for incremental adoption.

- Layouts

NextJs_1.webp

Next.js is a file-based routing system that uses folders to define routes. This system is designed to be intuitive and easy to use, and it offers a number of advantages over other routing systems.

  • First, file-based routing makes it easy to create and manage complex route hierarchies.
  • Second, it provides a clear separation between UI and routing logic, making it easier to maintain your codebase.
  • Finally, file-based routing is more performant than client-side routing, as it doesn’t require the browser to parse and execute JavaScript code.

However, some developers find file-based routing to be confusing and difficult to work with. As a result, next.js’s folder-based hierarchy may be a better fit for your project if you’re looking for a simpler routing solution.

- Server Components

Next.js is turning your mental model of how components work upside down! Instead, all the generated React code will run on the server by default and you must opt into having parts if it’s available for client Side rendering with module statements at top levels like before.

The app/ directory introduces support for React’s new Server Components architecture. It uses the server and client to come out at their best by allowing one to build fast, highly-interactive apps with a single programming model which ultimately provides excellent developer experience and efficiency.

By this, we are laying the foundations for the future so that we can build complex interfaces by reducing the amount of Javascript sent to clients and enabling faster initial page load.

When a route is loaded, the Next.js and React runtime will be loaded, which is cacheable and predictable in size. This runtime does not increase in size as your application grows.

Further, the runtime is asynchronously loaded, enabling your HTML from the server to be progressively enhanced on the client.

- Font Optimization

The new @next/font module allows you to optimize your Web Fonts during build time.

It downloads and hosts them in a private folder, saving an additional round trip for each font file downloaded from the server as well as delivering it quickly without having another set of handshake with any remote servers or services.

Which means, what is delivered has not been altered along its journey through our network layer — this means faster load times on pages where these fonts are used!

Remember that when using this package, then it’s important to have a working internet connection when you run your development build the first time so it can cache it properly, otherwise, it will fall back to system fonts if adjustFontFallback is not set.

Apart from these also, there are a few features due to which Next JS is much more reliable and good than other frameworks.

Should I Upgrade To Next.js 13?

If you mean actually using and taking advantage of all the shiny new features you now have…I’d advise waiting.

Next.js 13 is a very early beta release that heavily utilizes cutting-edge features from React 16 and 17, often not implementing them fully yet due to their lack of stability in the form.

It has an extremely poor developer experience at this point with no documentation available other than third-party tutorials on YouTube which can lead you to make costly mistakes when trying something new — such as pipe characters being treated like spaces!

Wrap Up

There’s no need to worry if you want a simple website with Next.js! This release gives us some insight into how things are going in the future, and it makes our framework even more robust behind the scenes because we’ll be able to use these new features once they’re available on all platforms (firefox).

As long as, you manage your expectations about what now have currently — don’t expect drastic changes right away though.

Share:
0
+0