Sling Academy
Home/Next.js/Page 7

Next.js

How to use Tailwind CSS in Next.js

How to use Tailwind CSS in Next.js

Updated: Apr 27, 2023
This succinct article shows you how to integrate TailwindCSS in Next.js. A Quick Introduction TailwindCSS is a popular CSS framework that can help you create nice user interfaces quickly with pre-made CSS classes. Unlike MUI,......

How to Upgrade an Existing Next.js Project

Updated: Apr 27, 2023
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 up-to-date with the latest features and functionality of the......
Next.js: How to Extract Request Headers (4 Approaches)

Next.js: How to Extract Request Headers (4 Approaches)

Updated: Apr 27, 2023
This article shows you a couple of different ways to extract request headers in Next.js (we will focus on Next.js 13 and use TypeScript in the upcoming examples). What are request headers? Request headers are a part of the HTTP......
Next.js Error: Hooks are not Allowed in Server Components

Next.js Error: Hooks are not Allowed in Server Components

Updated: Apr 26, 2023
The problem When working with a new version of Next.js (13.x or higher) and using the app directory instead of the traditional pages directory, you might run into the ReactServerComponentsError error. The error messages will look as......
Next.js: Using getServerSideProps() with TypeScript

Next.js: Using getServerSideProps() with TypeScript

Updated: Mar 28, 2023
Overview In Next.js, the getServerSideProps() function is a way to fetch data on the server side and pass it as props to your page component. It is useful for dynamic data that changes often and needs to be updated on each......

How to Import & Display Local Images in Next.js

Updated: Mar 28, 2023
When developing web apps with Next.js, there might be cases where you want to import and use local images instead of network images, such as logos, placeholders, download buttons, background images, etc. The best place to store local......
Next.js: How to organize code in an “src” folder

Next.js: How to organize code in an “src” folder

Updated: Mar 27, 2023
By default, Next.js puts your pages folder in the root directory of your project. However, you can store your source code (including pages, components, CSS styles, and utility functions) in an src folder (the name src is a convention......
Next.js getServerSideProps(): Tutorial & Example

Next.js getServerSideProps(): Tutorial & Example

Updated: Mar 22, 2023
Overview getServerSideProps() is a Next.js asynchronous function that can be exported from a page component (in your pages folder) to fetch data at the requested time on the server side before rendering the page. It is useful for......
Next.js: Read and Display Data from a Local JSON File

Next.js: Read and Display Data from a Local JSON File

Updated: Feb 08, 2023
This short and straight-to-the-point article shows you how to read and display data from a local JSON file in Next.js. This is useful if you want to build a small web app quickly without having to code the backend or spend time setting up......

Next.js API Routes: How to Get Parameters & Query String

Updated: Jan 14, 2023
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 database and send them to the client. To get a list of products, use......

Next.js: How to Disable/Enable React Strict Mode

Updated: Jan 14, 2023
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, etc. In Next.js, React Strick Mode is turned on by default for the......
Next.js: How to Get User’s IP Address

Next.js: How to Get User’s IP Address

Updated: Jan 14, 2023
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 to serve different content for each region or just for analytics purposes). You can do so on the......