Mark Ku's Blog

Introduction

This afternoon, I upgraded our company's project from Next.js 12 to Next.js 13. The Next.js release cycle is really fast, and Next.js 13 brings us several new features:

  • A new web build tool, Turbopack (Rust-based), which improves site build performance (at least 3x faster, according to official data).
  • Simplified next/link syntax => it now renders its own <a> tag, so you no longer need to wrap it in one.
  • A rewritten next/image component => it now uses the browser's native lazy loading. Older versions of Safari will fall back to preloading. The layout attribute has been removed, and the alt attribute is now mandatory.
  • next/font => makes it easier to load Google Fonts.
  • Initial support for async Server Components
  • Fixes for various framework bugs.

Testing Build Performance

In my test of the site build (npm run build), the speed nearly doubled. Next.js 12 local build: 1 minute 40 seconds
Next.js 13 local build: 56 seconds
Upgrading to Next.js 13 brought a noticeable improvement in page rendering performance.

Next Image

New syntax for loading images. Every Image component now requires an alt prop, or it will throw an error. New Image component examples

import Image from 'next/image';

<Image
loader={cloudflareLoader}
src={contentURL + item.Image}
width={600}
height={350}
></Image>

However, since Next.js 13 removed the layout prop from Image, the layout on many of our pages broke. Most cases can be fixed by following the example below.

<Image
alt=""
loader={cloudflareLoader}
src={contentURL + item.Image}
width={600}
height={350}
style={{
width: '100%',
height: 'auto',
}}
></Image>

New syntax for responsive images

<Image
alt=""
loader={cloudflareLoader}
src={contentURL + item.Image}
width={600}
height={350}
sizes="100vw"
style={{
width: '100%',
height: 'auto',
}}
></Image>

If you can't upgrade right away, you can still use the old Image component

 import Image from next/legacy/image

Old syntax

<Link href="/about">
  <a>About</a>
</Link>

New syntax

<Link href="/about">
  About
</Link>

P.S. You can modify your next.config.js to keep the Next.js 12 syntax (not recommended, as the new version fixes link-related bugs).

 experimental: {
       newNextLinkBehavior: false,
 },

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11
NEXTJS 13 昇級筆記 - Mark Ku's Tech Notes