How to Upgrade an Existing Next.js Project
This article will show you how to upgrade an existing Next.js project to the latest version. This will ensure that your application is secure, performs well, and is…
Next.js: How to set HTML lang attribute
When building a web application, you can set the lang attribute of the <html> tag to explicitly declare the language used on your pages. For example, an app…
Next.js API Routes: How to Get Parameters & Query String
With Next.js, you can build your backend API right in the pages/api directory of your project. Suppose you want to fetch data about some fictional products from your…
Next.js: How to Disable/Enable React Strict Mode
React Strict Mode is a tool that runs in development mode only. It checks and highlights potential issues in your application, such as unsafe lifecycles, legacy API usage,…
Next.js: How to Get User’s IP Address
There might be cases where you want to get the IP address from where the user is viewing the current page of your Next.js app (e.g., you want…
How to Run Next.js on Custom Ports
By default, a Next.js app will run on port 3000 (both in the development and production environments). However, you can use another port if you like. This short…
Solving the ‘Window is Not Defined’ Error in Next.js
This article shows you a few solutions to fix the window is not defined error in Next.js. Understanding The Problem When working with Next.js, you are likely to…
How to Detect Server vs Client Environment in Next.js
In Next.js, you can programmatically detect between the server environment and the client environment by checking whether the window object exists or not, like this: Because the window…
Next.js: 2 ways to fix the ‘document is not defined’ error
When working with Next.js, you might encounter the document is not defined error. This article will explain why this error happens, then walk you through a couple of…
How to style Link component in Next.js
In Next.js, <Link> is one of the most-used components. To style it, you can use the className or the style props (in the old days, we had to…