<Image\>
Component!img
.com/nl-nl/product
ScriptLoader
componentImage
#jss-server-side
packages.json
use workspaces
npm install user/project#pull/123
package.exports
npx
rewrite using npm exec
npm ls
only outputs top-level deps, flag for fullloading = "eager"
and priority
useMutation
hook takes in server function and returns a client functionnpm install -g
useMutation
hook takes in server function and returns a client functionnpm install -g
Vercel hosted its first ever Next.js Conference last week. It was packed with exciting updates coming with Next.js 10 and filled with awesome guest speakers.
They had four "stages" going, which were basically four different Youtube live channels playing pre recorded talks at once. As an attendee, you were free to hop around any of them based on the content and your interests. While most of the speakers were speaking on subjects somewhat related to Next, there were also other presentations from around the React and NPM ecosystem more generally.
All presentations will soon be publicly available at https://nextjs.org/conf. I will go through some of the biggest takeaways that stood out to me.
Next.js 10 News
There is a ton of exciting news coming with Next.js 10, but I'm going to share my favorite three.
Image
The biggest feature coming with Next.js 10 is the new Image
component.
Images are hard to load in a performant way and could often slow down your app. Next is looking to tackle some of the biggest optimization hurdles related to Images all with one component:
Image
component solves this by automatically generating a srcset
property to render differently sized images at different view ports.webp
and avif
are shown to be 25-34% smaller than the standard jpg
s and png
s. Next will now automatically serve the images in modern formats for browsers that support it.Beware that the Image component only works with server side rendering, which includes next start
and next build
. It does not support static side generation in next export
. Currently images that are exported will 404. To follow along the resolution to this problem, check out this issue.
Internationalization
Next.js 10 is also introducing the first of a series of features to support Internationalization. In this release, they are offering built-in support for routing.
In your next.config.js
, you could specify the locales that your app supports and which domains they map to. Next will then handle all of the routing under the hood when generating your static HTML pages.
// next.config.js
module.exports = {
i18n: {
locales: ['en', 'nl'],
domains: [
{
domain: 'example.com',
defaultLocale: 'en'
},
{
domain: 'example.nl',
defaultLocale: 'nl'
}
]
}
}
You could then use your application logic to read the locale and render the appropriate language text.
Analytics
Vercel is releasing an Analytics dashboard for all Vercel deployed Next.js apps. You could get started at https://nextjs.org/analytics.
With their solution, Vercel is making the claim that you cannot truly test performance in development environments. I've found this to be largely true in my experience. Live data shape and traffic are incredibly difficult to simulate. Being able to track performance metrics on your live application over time will lead to more impactful changes.
The metrics they are targeting are based on three web vitals that they have collaborated with Google to land on:
All three will be tracked upon enabling analytics on Vercel deployments. In order to enable analytics on any hosted deployment, you will need to contact Vercel's sales team.
For all features coming with Next.js 10, be sure to check out Vercel's blog post.
Talks That Stood Out
With four tracks of talks running all day, there were plenty of guest speakers at the virtual conference. Three of them in particular stood out to me.
Changing Lanes With Lyft
Joshua Callendar talked about the evolution of building web apps at Lyft. They started off as an Angular shop, but began experimenting with Next.js when they started to experience performance problems with Angular. They built various web infrastructure components to help migrate their hundreds of services over, including one that resembles create-next-app and a various code mods.
The talk highlighted to me the difficulty in modernizing. They faced some core issues in maintaining multiple frontend services which included architecture drift and a lack of standardization. Their internal Frontend Build service improved how apps going forward were built, but all existing apps struggled to migrate to the modern approach.
Next.js helped solve the lack of standardization for Lyft by taking care of most of the Webpack configuration and project hierarchy standards. They then build a service around jscodeshift to safely update code from old projects to the modern approach.
The talk highlighted a real world example of a company taking a convergence approach with all of their services. I was also surprised that Lyft, which seems like a simple ride-sharing service, could still scale to have hundreds of microservice applications.
Future of Performance and Data in the Modern Web
This was a panel moderated by Kevin Van Gundy that included:
In it they talked about the future of maintaining high performing web applications. November 5th, 2020 rewatch talk
Blitz.js - Fullstack Framework for Next.js
Creator of Blitz Brendan Bayer gave a rundown of the web framework he built on top of Next. Blitz aims to be an opinionated full-stack monolith, that bundles together everything you need for any web application from authentication to database access. You could check out the project here.
I think this is the next evolution of web apps. Now that the frontend ecosystem has matured around React and Vue, the next stage is for full stack web frameworks to develop. I expect the "React for full stack" to include everything you need, including easy to build APIs, cloud provider resources, and continuous integration. Regardless of whether or not Blitz.js will play a role in this space, it has definitely inspired me to think about what a full stack web framework should look like according to my tastes.
Final Takeaways
The overall theme I got from the conference was one of convergence. After years of rapid trial and error, the web developer community is converging on a set of best practices. Many new technologies are being released with the approach of choosing convention over configuration, so that as a developer you could get started as fast as possible with as many best practices included as possible.