How to make An input box as both Search-box and select-box on next.js

Below is the code for making an input box to both the search and select box const CreateArticle = () => { const [tags, setTags] = useState([]); const [searchTerm, setSearchTerm] = useState(”); const [selectedTags, setSelectedTags] = useState([]); const [activeTab, setActiveTab] = useState(“create”); // “create” or “preview” const [newTag, setNewTag] = useState(”); /* Tag section*/ //… Continue reading How to make An input box as both Search-box and select-box on next.js

To display tags in the preview section on Knowledge base

<p className=“post-main-header-categoryTags text-left mt-5 mb-2”> <span className=“popup-knowledgebase-forumTagSpan “>Tags:{” “}</span> <p className=‘popup-knowledgebase-forumInnertag’> {previewContent.selectedTags .map((tagId) => { const tag = tags.find((tag) => tag.id === tagId); return tag ? tag.name : tagId; // Use tag name or tagId as per your data structure }) .join(“, “)} </p> </p>

Enable AMP in Next.js?

This is an important question and is asked in many Next.js interview questions. There are two ways to enable AMP in Next.js. AMP-First Pages Hybrid AMP Pages AMP-First Pages: The AMP-First Pages are served to the primary traffic of the website as well as traffic generated from the search engine. Use the following syntax to implement… Continue reading Enable AMP in Next.js?

How to set up CDN in Next.js?

To setup CDN in Next.js, the developers have to follow the steps given below: To start, we have to first set up the “assetPrefix” setting and configure our CDN origin to support and resolve the domain that our Next.js is hosted on. const isProd = process.env.NODE_ENV === ‘production’;    module.exports = {   // You may only need to add assetPrefix in the production.    assetPrefix: isProd ? ‘https://cdn.mydomain.com’ : ”   };   If the CDN is present on a separate… Continue reading How to set up CDN in Next.js?

Recommended method to fetch data in Next.js?

There are multiple ways to fetch data in Next.js, but Next.js itself recommends getInitialProps, an async function to retrieve data from anywhere. When we use getInitialProps to retrieve data, it receives a context object which has the following properties: pathname- It specifies the path section of the URL. query- It is used to specify the query string section of URL parsed… Continue reading Recommended method to fetch data in Next.js?

Styling in Next.js(React Js)

Styling in Next.js offers flexibility, and you can choose from various approaches. There exist 2 popular approach. CSS-in-JS with styled-components and traditional CSS with CSS modules 1.CSS-in-JS with Styled-Components: // components/Button.js import styled from ‘styled-components’; const StyledButton = styled.button`padding: 10px 15px;font-size: 16px;color: white;background-color: ${(props) => (props.primary ? ‘blue’ : ‘green’)};border: none;border-radius: 5px;cursor: pointer; &:hover {background-color:… Continue reading Styling in Next.js(React Js)

Add Background image from external source(backend) in Next JS/Reach JS

While we are connecting the leading frontend technologies like Next js, Vue js , React etc with Net Suite, WordPress like headless sources, its important to know that to add background images to the frontend via backend. In my scenario, i have to set the background image of a swiper carousel from the backend. The… Continue reading Add Background image from external source(backend) in Next JS/Reach JS

Include JSON Lottie files in Next JS Project

Sometimes, there might be situation arises where we have to add JSON Lottie files in our project for improving UI and also making user friendly. We cannot directly use Lottie files in Next JS project instead we have to do the followings. Install lottie-react using npm i lottie-react –legacy-peer-deps Create a folder to add Lottie… Continue reading Include JSON Lottie files in Next JS Project

Setting Scroll Bar Thumb width using CSS

Sometimes, there might be situation arrises where we have to setup or adjust the scroll bar thumb width for making it user friendly. But we cannot directly change the width of this by using css infact we can adjust the border width so that this makes an illusion that the width is very small. Here… Continue reading Setting Scroll Bar Thumb width using CSS

Advantages of Next JS as a frontend Framework.

As React became the most widely adopted web framework, encompassing over 40% of developers in 2021 according to Statista, Next.js adoption has also grown dramatically. Vercel, the company that maintains Next.js, cites over 6 million downloads since its launch and 50% usage growth in the top ten-thousand websites for the period of October 2020 to… Continue reading Advantages of Next JS as a frontend Framework.