Read this guide to get useful insights and best practices on how to prepare your Next.js site for production!
Is important your team or team's know how to optimize the application for end-users.
In this post, you will dig into the commons strategies and best practices to deploy Next.js to production!
1. Use always Image Optimization
2. Use Font Optimization
next/font optimizes local fonts and removes external network requests for improved privacy and performance. As of Next.js 13, it supports self-hosting on any Google Font to avoid making requests to retrieve font files from Google.
3. Use Script Optimization
4. Integrate an Analytics or APM Tool
Once a Next.js site is in production, you need a way to track its performance. In particular, you should have a system in place to monitor page views and get information about site traffic.
When deploying to Vercel, you can achieve that with Next.js Speed Insights. This tool allows you to analyze and measure the performance of your application’s pages using various metrics.
5. Enable Error Handling With Custom 500 and 400 Pages
Like any other application, Next.js sites are subject to errors. One of the most important aspects of error handling is presenting meaningful error messages to users to inform them of what happened. When an error occurs in the frontend or backend, Next.js displays static 500 page.
6. Optimize Page SEO Performance With Lighthouse
The ultimate goal of most Next.js sites is to produce excellent SEO results. Google has changed its approach to SEO performance evaluation a great deal over time, and it now focuses primarily on Core Web Vitals: