Adding New Menu in Payload

How to Create a New Menu in Payload ? Create a Custom Component: Create a React component for your new menu. import { slateEditor } from ‘@payloadcms/richtext-slate’ import path from ‘path’ import type { CollectionConfig } from ‘payload/types’ export const Test: CollectionConfig = {  slug: ‘test’,  upload: {   staticDir: path.resolve(__dirname, ‘../../../test’),  },  access: {   read:… Continue reading Adding New Menu in Payload

Using the Next.js Image component for optimized images

The Next.js Image component is a powerful tool for optimizing images in web applications, enhancing performance and user experience. Here’s a brief overview of how to use it effectively: Key Features Automatic Image Optimization: Images are automatically optimized on demand, ensuring the best possible performance without manual intervention. Responsive Images: Generates multiple versions of an… Continue reading Using the Next.js Image component for optimized images

Internationalization functionality in Nextjs

Setting up i18n in Next.js: Configure i18n settings in your next.config.js file, specifying the supported locales and the default locale. Locale Detection: Next.js automatically detects the user’s locale based on their location and browser settings. You can control this behavior by adjusting the localeDetection setting in next.config.js. Implementing Localization: Next.js supports various i18n libraries such… Continue reading Internationalization functionality in Nextjs

Node Js App to call back an API

Here is an example of an API to send back an API response when something is posted into and API and called it to an another API. Folder Structure is Like // src/routes/index.js const express = require(‘express’); const router = express.Router(); const axios = require(‘axios’); router.post(‘/fetchStatement’, async (req, res, next) => { try { const… Continue reading Node Js App to call back an API

Deploy the Node.js in Render.com for free.

Create a Node.js project and deploy the codes into the GitHub by creating a new repository. Login to the website of Render Dashboard using the GitHub account and “Authorize Render.” Enter the email and complete signup. Select “New Web Services”. Click “Connect to GitHub”. Select the repository as our requirements. Fill the fields that needed… Continue reading Deploy the Node.js in Render.com for free.

Workflow of connecting MariaDB (mysql) with the Database

Open XAMPP and enable Apache and mysql in the XAMPP. A database was created in the http://localhost/phpmyadmin/index.php. I have created a table width database name “nodedb” and table name users. I have entered some values in the columns, and I have to get the values as API in the frontend. For database connection, I have… Continue reading Workflow of connecting MariaDB (mysql) with the Database

Server side data fetching and using in the components.

Use server-side data fetching in the parent page.js. Create a component in the Next js and call it in this page.js file. Send the data that has been fetched from the Rest API endpoint. Call the value in the component which has been imported to the parent component. Then use the values as needed in… Continue reading Server side data fetching and using in the components.

Date Validation and Comparison with Moment.js

Installing Moment.js: npm install moment Importing Moment.js: import moment from ‘moment’; Checking if a Date is Valid: One common task when working with dates is validating whether a given date is in a valid format. Moment.js simplifies this process using its parsing functionality. const dateStr = ‘2022-04-30’; const isValid = moment(dateStr, ‘YYYY-MM-DD’, true).isValid(); console.log(isValid); //… Continue reading Date Validation and Comparison with Moment.js

Map vs FlatMap: Next.js

Map: Definition: The map method is used to iterate over an array and execute a provided function on each element of the array, creating a new array with the results of calling the function for each element. Practical Use: Transforming data: map is commonly used to transform arrays of data into a new format. Rendering… Continue reading Map vs FlatMap: Next.js