Next.js 13… this changes everything

Fireship · Intermediate ·🌐 Frontend Engineering ·3y ago

Key Takeaways

Next.js 13 introduces a new build tool called Turbo Pack, a new routing system, and improved data fetching capabilities, making it a game-changer for web development. The new features include a directory-based routing system, server components, and caching, which provide a faster and more efficient developer experience.

Full Transcript

it is October 26 2022 and you're watching the code report just when you thought you had web development all figured out Along Comes an entirely new build tool and a complete overhaul of your favorite framework we're ready for a new paradigm not enough men's and disease of evil the reality [Music] JavaScript it's a wild ride next JS comp happened yesterday and they made an extremely ballsy move to take the world's most popular JavaScript framework and linchpin of a unicorn startup and totally change up the developer experience as you're about to see these new features are game changing and blazingly fast but they're not without their trade-offs buckle up because we've got a lot to unpack starting with a brand new build tool called turbo pack now I know you just switched over to the next gen build tool V last week but a new character is spawned versel employs Tobias coppers the creator of webpack who knows a thing or two about module bundling turbo pack was built from the ground up with rust which appeals to our novelty bias and it integrates turbo repo to Cache duplicate operations together these factors can satisfy your need for blazingly fast speed turbo pack shows updates 10 times faster than Veet and 700 times faster than webpack shots fired shots fired turbo pack sounds amazing but it's currently an alpha and I'm a bit skeptical there's a massive ecosystem of webpack plugins that will likely make migration very hard for existing apps Versa will likely need to count on community contributions with some kind of plug-in system and that might be difficult because JavaScript developers like me are too dumb and lazy to learn rust furthermore these speed gains are mostly relevant to Big Enterprise projects where teams over engineer these giant monstrosities to guarantee job security Veet with es build is already fast enough for most projects and it's got an awesome developer experience that's hard to beat you should also know that Purcell has an angle to make money on this by remotely caching builds in the cloud and parcel has been using this architecture for a long time as well what's way more exciting for me is the brand new routing system the best possible router which adds a smorgasbord of new possibilities and performance improvements to the framework these are huge changes that they worked on directly with the react core team but before you freak out everything can be incrementally adopted so it won't break your existing project next 13 adds a new app directory that also uses file system-based routing like before but now it's all directory based along with a bunch of naming conventions for different use cases to create a page you give the direct the name of the route then add a page.js file to it that exports the component you want to display there nice and simple however because it's a directory we can co-locate extra components here as well instead of needing to create a separate components directory or some other kind of convention more importantly though it opens the door to layouts and nested routing when you give a file the name of layout.js it creates a UI that can be inherited by the child routes and when you navigate to a route inside of a layout only the inner UI is rendered as opposed to the entire page this is really cool because we also have file naming conventions for loading and error that can render a different UI at the component level based on its current state for example if the component breaks it will render error.js instead of page.js while the rest of the UI stays intact and this just makes life so much easier but by far the most epic feature in this new release is data fetching next is what you would almost call the official react framework now that's our endorsement that this is the data fetching solution for react that everyone I think has been been waiting for what I I haven't told you yet is that all of these components are react server components by default server components are a low level primitive in react that enables server-side rendering but until now they've always been kind of difficult for the common developer to use it's a huge deal because now we can totally get rid of things like get static props and get server-side props instead we can just write a plain JavaScript function that uses Fetch and then await the result of that function directly in a component no need to pass props back and forth between client and server it feels totally natural like you're just using vanilla JavaScript and you don't even need to serialize data which can be a major pain Point furthermore you can take Concepts like ISR SSR and SSG and remove them from your brain the new mental model revolves entirely around caching by default all pages will be cached to provide the performance of a static site but if you want new data on every request like SSR you can add the Cache no store option to fetch or for incremental static regeneration use the next option with the number of rebalidate seconds and what's also amazing about all this is that the UI can be incrementally streamed in thanks to react suspense all you have to do is Define a loading.js file to define the UI if a component is still awaiting data it will automatically show it at the component level while rendering everything else in the application game changing but many of these features are clearly inspired by remix credit where credit is due but all is fair in love and MIT license code but one thing next is missing is a way to write data similar to remix forms which I think is a really great feature and weirdly there's no way to write API routes in the new app directory as far as I can tell and to me that just seems like a sloppy loose end as I showed data fetching looks amazing but mutations are an entirely different story in the docs it says the next team is working on a new RFC for mutating data but currently you would use a client-side component write your mutation logic then pass a callback function of refresh to update any data on that route after the mutation is complete this is kind of similar to how things work in react query but it seems like the framework could provide a more intuitive solution here overall I think next 13 looks amazing however these are major changes that basically make every next JS tutorial out there obsolete even if these changes are a step forward the reality is that people don't like change like people were riding in the streets when view 2 went to view 3 even though it too can be adopted incrementally right now everybody's super excited about these new features but if you're the guy that has to migrate all that code your initial excitement might soon turn to anger another criticism is that a Hello World app is still 90 kilobytes of JavaScript it seems like it should be able to ship zero JavaScript apps like Astro quick and so on but that doesn't appear to be the case in addition to the features I mentioned there are all kinds of small optimizations and one of them was even inspired by a video I made Edge functions can now be set to a specific region and it's great to see these big companies recognize that the shape of the planet is not an oblate sphere but rather a level plane and lastly I'm working on a longer full tutorial for next 13 which will be on my new channel Beyond fireship so make sure to subscribe over there this has been the code report thanks for watching and I will see you in the next one [Music]

Original Description

Next.js version 13 was announced yesterday and it brings huge changes to the framework. They collaborated directly with the React team to create the ultimate web framework and a new webpack replacement built with Rust... let's take a first look. #javascript #tech #TheCodeReport 💬 Chat with Me on Discord https://discord.gg/fireship 🔗 Resources Next 13 Announcement https://nextjs.org/blog/next-13 Turbopack Announcement https://vercel.com/blog/turbopack Next.js Full Course https://fireship.io/courses/react-next-firebase/ Next in 100 Seconds https://youtu.be/Sklc_fQBmcs 🔥 Get More Content - Upgrade to PRO Upgrade at https://fireship.io/pro Use code YT25 for 25% off PRO access 🎨 My Editor Settings - Atom One Dark - vscode-icons - Fira Code Font 🔖 Topics Covered - What changed in Next.js 13? - Should I upgrade to Next 13? - Next.js vs Remix - Next.js vs Nuxt - Vite vs Turbopack - Replacing webpack with Turbopack
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Fireship · Fireship · 0 of 60

← Previous Next →
1 Angular 4 Development and Production Environments with Firebase
Angular 4 Development and Production Environments with Firebase
Fireship
2 OAuth with Angular and Firebase Tutorial
OAuth with Angular and Firebase Tutorial
Fireship
3 Anonymous Authentication with Angular and Firebase - Lazy Registration
Anonymous Authentication with Angular and Firebase - Lazy Registration
Fireship
4 Angular Router Guards for Firebase Users
Angular Router Guards for Firebase Users
Fireship
5 Angular Firebase CRUD App with NoSQL Database Tutorial
Angular Firebase CRUD App with NoSQL Database Tutorial
Fireship
6 Upload Files from Angular to Firebase Storage
Upload Files from Angular to Firebase Storage
Fireship
7 How to Deploy an Angular App to Firebase Hosting
How to Deploy an Angular App to Firebase Hosting
Fireship
8 Sharing Data between Components in Angular
Sharing Data between Components in Angular
Fireship
9 Loading Spinners for Asynchronous Firebase Data
Loading Spinners for Asynchronous Firebase Data
Fireship
10 Angular 4 Transactional Email with Google Firebase Cloud Functions
Angular 4 Transactional Email with Google Firebase Cloud Functions
Fireship
11 Firebase Database Rules Tutorial
Firebase Database Rules Tutorial
Fireship
12 Autocomplete Search with Angular4 and Firebase
Autocomplete Search with Angular4 and Firebase
Fireship
13 Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Fireship
14 Angular Drag-and-Drop File Uploads to Firebase Storage
Angular Drag-and-Drop File Uploads to Firebase Storage
Fireship
15 Text Translation with Firebase Cloud Functions onWrite and Angular 4
Text Translation with Firebase Cloud Functions onWrite and Angular 4
Fireship
16 Custom Usernames with Firebase Authentication
Custom Usernames with Firebase Authentication
Fireship
17 Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Fireship
18 Simple Pagination with Firebase and Angular 4
Simple Pagination with Firebase and Angular 4
Fireship
19 How to Connect Firebase Users to their Data - 3 Methods
How to Connect Firebase Users to their Data - 3 Methods
Fireship
20 Add Toast Message Notifications to your Angular App
Add Toast Message Notifications to your Angular App
Fireship
21 Facebook-Inspired Reactions System with Angular and Firebase
Facebook-Inspired Reactions System with Angular and Firebase
Fireship
22 Learn NgModule in Angular with Examples
Learn NgModule in Angular with Examples
Fireship
23 Lazy Loading Components in Angular 4
Lazy Loading Components in Angular 4
Fireship
24 Stripe Checkout Payments with Angular and Firebase - Part 1
Stripe Checkout Payments with Angular and Firebase - Part 1
Fireship
25 Process Stripe Payments with Firebase Cloud Functions - Part 2
Process Stripe Payments with Firebase Cloud Functions - Part 2
Fireship
26 Selling Digital Content in Angular with Stripe Payments - Part 3
Selling Digital Content in Angular with Stripe Payments - Part 3
Fireship
27 Angular 4 Full Text Search with Algolia - Part 1
Angular 4 Full Text Search with Algolia - Part 1
Fireship
28 Algolia with Firebase Cloud Functions - Part 2
Algolia with Firebase Cloud Functions - Part 2
Fireship
29 Firebase Phone Authentication in Angular 4
Firebase Phone Authentication in Angular 4
Fireship
30 Top 7 RxJS Concepts for Angular Developers
Top 7 RxJS Concepts for Angular Developers
Fireship
31 Learn Angular Animations with 5 Examples
Learn Angular Animations with 5 Examples
Fireship
32 Advanced Firebase Data Filtering (Multi-Property)
Advanced Firebase Data Filtering (Multi-Property)
Fireship
33 Realtime Maps with Mapbox + Firebase + Angular
Realtime Maps with Mapbox + Firebase + Angular
Fireship
34 Angular Reactive Forms with Firebase Database Backend
Angular Reactive Forms with Firebase Database Backend
Fireship
35 Send Push Notifications in Angular with Firebase Cloud Messaging
Send Push Notifications in Angular with Firebase Cloud Messaging
Fireship
36 Top 7 Ways to Debug Angular 4 Apps
Top 7 Ways to Debug Angular 4 Apps
Fireship
37 Infinite Scroll with Angular and Firebase
Infinite Scroll with Angular and Firebase
Fireship
38 Use TypeScript with Firebase Cloud Functions
Use TypeScript with Firebase Cloud Functions
Fireship
39 Realtime Graphs and Charts with Plotly and Firebase
Realtime Graphs and Charts with Plotly and Firebase
Fireship
40 Role-Based User Permissions in Firebase
Role-Based User Permissions in Firebase
Fireship
41 User Presence System in Realtime - Online, Offline, Away
User Presence System in Realtime - Online, Offline, Away
Fireship
42 Location-based Queries with GeoFire and Angular Google Maps
Location-based Queries with GeoFire and Angular Google Maps
Fireship
43 Angular ngrx Redux Quick Start Tutorial
Angular ngrx Redux Quick Start Tutorial
Fireship
44 Angular Ngrx Effects with Firebase Database
Angular Ngrx Effects with Firebase Database
Fireship
45 Progressive Web Apps with Angular
Progressive Web Apps with Angular
Fireship
46 Angular Ngrx with Firebase Google OAuth User Authentication
Angular Ngrx with Firebase Google OAuth User Authentication
Fireship
47 RxJS Quick Start with Practical Examples
RxJS Quick Start with Practical Examples
Fireship
48 Send SMS Text Messages with Twilio and Firebase
Send SMS Text Messages with Twilio and Firebase
Fireship
49 Firebase Database Performance Profiling
Firebase Database Performance Profiling
Fireship
50 Native Desktop Apps with Angular and Electron
Native Desktop Apps with Angular and Electron
Fireship
51 Subscription Payments with Stripe, Angular, and Firebase
Subscription Payments with Stripe, Angular, and Firebase
Fireship
52 Firestore with AngularFire5 Quick Start Tutorial
Firestore with AngularFire5 Quick Start Tutorial
Fireship
53 Angular HTTP Client Quick Start Tutorial
Angular HTTP Client Quick Start Tutorial
Fireship
54 Google Sign-In with Firestore Custom User Data
Google Sign-In with Firestore Custom User Data
Fireship
55 Star Review System from Scratch with Firestore + Angular
Star Review System from Scratch with Firestore + Angular
Fireship
56 Angular Chatbot with Dialogflow (API.ai)
Angular Chatbot with Dialogflow (API.ai)
Fireship
57 Learn @ngrx/entity and Feature Modules
Learn @ngrx/entity and Feature Modules
Fireship
58 Infinite Scroll Pagination with Firestore
Infinite Scroll Pagination with Firestore
Fireship
59 Faster Firestore via Data Aggregation
Faster Firestore via Data Aggregation
Fireship
60 Contentful - CMS for Angular Progressive Web Apps
Contentful - CMS for Angular Progressive Web Apps
Fireship

Next.js 13 introduces a new build tool, routing system, and data fetching capabilities, making it a game-changer for web development. Learn how to use Turbo Pack, server components, and caching to build fast and efficient web applications.

Key Takeaways
  1. Install Next.js 13 and Turbo Pack
  2. Create a new project with the new directory-based routing system
  3. Use server components for improved data fetching
  4. Implement caching for improved performance
  5. Use React Suspense for incremental rendering
  6. Migrate existing projects to Next.js 13
💡 Next.js 13 provides a faster and more efficient developer experience with its new build tool, routing system, and data fetching capabilities.

Related Reads

Up next
Elementor Angie Ai Plugin Tutorial
Quick Tips - Web Desiign & Ai Tools
Watch →