<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adeeko Tobiloba Isreal</title>
    <description>The latest articles on DEV Community by Adeeko Tobiloba Isreal (@isreal).</description>
    <link>https://dev.to/isreal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F901149%2F09d46e42-2506-4381-8058-b6a0bfba94d8.jpeg</url>
      <title>DEV Community: Adeeko Tobiloba Isreal</title>
      <link>https://dev.to/isreal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isreal"/>
    <language>en</language>
    <item>
      <title>A comprehensive guide to understanding array methods in Javascript</title>
      <dc:creator>Adeeko Tobiloba Isreal</dc:creator>
      <pubDate>Mon, 28 Aug 2023 16:53:09 +0000</pubDate>
      <link>https://dev.to/isreal/a-comprehensive-guide-to-understanding-array-methods-in-javascript-lgd</link>
      <guid>https://dev.to/isreal/a-comprehensive-guide-to-understanding-array-methods-in-javascript-lgd</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Arrays are fundamental data structures in JavaScript that allow you to store and manipulate collections of elements. They provide a versatile way to manage data, and JavaScript provides a plethora of built-in methods specifically designed to make working with arrays efficient and convenient. These array methods empower developers to perform a wide range of operations, such as adding, removing, and modifying elements, as well as searching, sorting, and transforming arrays.&lt;/p&gt;

&lt;p&gt;In this comprehensive guide, we will delve into the world of array methods in JavaScript. Whether you're a beginner seeking to understand the basics or an experienced programmer aiming to level up your skills, this guide will cover the essentials and nuances of array methods. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Content:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introduction to array method

&lt;ul&gt;
&lt;li&gt;Understanding the importance of Array method&lt;/li&gt;
&lt;li&gt;How Array Methods Simplifies your code structure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Basic Array methods

&lt;ul&gt;
&lt;li&gt;Using forEach methods &lt;/li&gt;
&lt;li&gt;How to map array data&lt;/li&gt;
&lt;li&gt;How to use the filter method&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Implementing iterative array methods&lt;/li&gt;
&lt;li&gt;Understanding searching and sorting&lt;/li&gt;
&lt;li&gt;Manipulating Arrays with these array methods

&lt;ul&gt;
&lt;li&gt;Understanding the difference and usage of push and pop 
method&lt;/li&gt;
&lt;li&gt;Why and when should you use the shift and unshift method&lt;/li&gt;
&lt;li&gt;The importance of using spice method&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The essence of reduction and accumulation in Javascript

&lt;ul&gt;
&lt;li&gt;Understanding the reduce method&lt;/li&gt;
&lt;li&gt;Why should you use the reduceRight method?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Combining arrays in javascript&lt;/li&gt;
&lt;li&gt;How to combine arrays with the concat method&lt;/li&gt;
&lt;li&gt;Chaining array methods in javascript

&lt;ul&gt;
&lt;li&gt;Understanding chaining method &lt;/li&gt;
&lt;li&gt;Benefits of chaining method &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic familiarity with JavaScript syntax and concepts.&lt;/li&gt;
&lt;li&gt;Understanding of arrays and their role in programming.&lt;/li&gt;
&lt;li&gt;Knowledge of functions and their usage in JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide will provide a comprehensive understanding of array methods in JavaScript, suitable for both beginners and those with some programming experience. It covers essential concepts and progressively explores more advanced topics, enabling you to effectively utilize array methods to manipulate, transform, and optimize your arrays in JavaScript.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Introduction to array method
&lt;/h2&gt;

&lt;p&gt;Arrays are an integral part of JavaScript, allowing you to store collections of data in a single structure. However, working with arrays often involves performing various operations on their elements, such as iteration, transformation, filtering, and more. This is where array methods come into play. Array methods are built-in functions that provide a convenient and efficient way to work with arrays, simplifying complex tasks and making your code more readable and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. Understanding the Importance of Array Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Array methods bring several key advantages to your JavaScript coding endeavors:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Readability and Clarity:&lt;/strong&gt; Array methods are designed to perform specific tasks, making your code more self-explanatory. Instead of writing manual loops and complex logic, you can use array methods that have clear and descriptive names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Efficiency:&lt;/strong&gt; Array methods are optimized for performance, as they are implemented in lower-level languages and are designed to be highly efficient. This ensures that your operations on arrays are executed with minimal overhead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Less Error-Prone:&lt;/strong&gt; By relying on well-tested and widely-used array methods, you reduce the risk of introducing bugs and errors into your code.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Suppose you have an array of numbers and want to find the sum of all even numbers. Instead of manually looping through the array and implementing conditional checks, you can use the &lt;code&gt;reduce&lt;/code&gt; array method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5, 6, 7, 8];

const evenSum = numbers.reduce((acc, num) =&amp;gt; {
  if (num % 2 === 0) {
    return acc + num;
  }
  return acc;
}, 0);

console.log(evenSum); // Output: 20

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;II. How Array Methods Simplify Your Code Structure&lt;/strong&gt;&lt;br&gt;
Consider the scenario where you need to transform each element of an array into uppercase. Using a traditional loop, this might involve writing multiple lines of code. However, with array methods like map, you can achieve the same result more concisely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ['apple', 'banana', 'orange'];

const capitalizedFruits = fruits.map(fruit =&amp;gt; fruit.toUpperCase());

console.log(capitalizedFruits); // Output: ["APPLE", "BANANA", "ORANGE"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; method applies a function to each element of the array and returns a new array containing the transformed elements. This not only simplifies the code but also makes it easier to understand your intent at a glance.&lt;/p&gt;

&lt;p&gt;In this guide, we'll explore a variety of array methods, from the basic ones like forEach, &lt;code&gt;map&lt;/code&gt;, and &lt;code&gt;filter&lt;/code&gt;, to more advanced methods like reduce and concat. By the end, you'll have a solid grasp of how to leverage these methods to enhance the efficiency and readability of your JavaScript code.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Understanding Basic Array Methods
&lt;/h2&gt;

&lt;p&gt;Arrays in JavaScript become even more powerful with the use of array methods that provide intuitive ways to manipulate and transform array elements. Let's dive into some fundamental array methods:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. Using the forEach Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The forEach method allows you to iterate through each element of an array and perform a specified action for each element. It's particularly useful when you want to execute a function for its side effects, such as logging or modifying the array in place.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

numbers.forEach(number =&amp;gt; {
  console.log(number * 2);
});

// Output:
// 2
// 4
// 6
// 8
// 10

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;II. How to Map Array Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; method creates a new array by applying a function to each element of the original array. It's often used to transform data without modifying the original array.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javascript
Copy code
const numbers = [1, 2, 3, 4, 5];

numbers.forEach(number =&amp;gt; {
  console.log(number * 2);
});

// Output:
// 2
// 4
// 6
// 8
// 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;II. How to Map Array Data&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;map&lt;/code&gt; method creates a new array by applying a function to each element of the original array. It's often used to transform data without modifying the original array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const temperaturesCelsius = [25, 30, 18, 22, 28];

const temperaturesFahrenheit = temperaturesCelsius.map(tempC =&amp;gt; (tempC * 9/5) + 32);

console.log(temperaturesFahrenheit); // Output: [77, 86, 64, 71.6, 82.4]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;III. How to Use the Filter Method&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;filter&lt;/code&gt; method creates a new array containing elements that pass a certain condition specified by a callback function. It's handy for extracting specific items from an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ages = [18, 25, 30, 16, 22, 40];

const eligibleAges = ages.filter(age =&amp;gt; age &amp;gt;= 18 &amp;amp;&amp;amp; age &amp;lt;= 35);

console.log(eligibleAges); // Output: [18, 25, 30, 22]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These basic array methods provide the foundation for efficiently working with arrays in JavaScript. They allow you to &lt;code&gt;iterate&lt;/code&gt;, &lt;code&gt;transform&lt;/code&gt;, and &lt;code&gt;filter&lt;/code&gt; arrays, paving the way for more advanced operations. As we move forward, we'll explore additional methods that delve deeper into the world of array manipulation.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Implementing Iterative Array Methods
&lt;/h2&gt;

&lt;p&gt;Iterative array methods are essential tools for working with arrays in JavaScript. They allow you to perform operations on array elements by iterating over each element. Let's explore two widely used iterative array methods: &lt;code&gt;forEach&lt;/code&gt; and &lt;code&gt;map&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the forEach Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;forEach&lt;/code&gt; method is used to loop through each element of an array and apply a given function to it. It's particularly useful when you want to perform an action on each element without necessarily creating a new array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

numbers.forEach(number =&amp;gt; {
  console.log(number * 2);
});

// Output:
// 2
// 4
// 6
// 8
// 10

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using the map Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; method creates a new array by applying a function to each element of the original array. This is especially handy when you want to transform the data in the array without modifying the original array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const temperaturesCelsius = [25, 30, 18, 22, 28];

const temperaturesFahrenheit = temperaturesCelsius.map(tempC =&amp;gt; (tempC * 9/5) + 32);

console.log(temperaturesFahrenheit); // Output: [77, 86, 64, 71.6, 82.4]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These iterative methods offer concise ways to work with arrays. While &lt;code&gt;forEach&lt;/code&gt; is suitable for actions with side effects, &lt;code&gt;map&lt;/code&gt; is ideal for creating a new array based on the transformation of existing elements. By utilizing these methods effectively, you can simplify your code and enhance its readability.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Understanding Searching and Sorting
&lt;/h2&gt;

&lt;p&gt;Searching for specific elements and sorting the contents of an array are common tasks when working with data. JavaScript provides array methods to help you efficiently accomplish these tasks. Let's explore find, indexOf, and sort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the find Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The find method is used to search for the first element in an array that satisfies a given condition. It returns the value of the first element found, or undefined if no matching element is found.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ['apple', 'banana', 'orange', 'grape'];

const fruitWithSixLetters = fruits.find(fruit =&amp;gt; fruit.length === 6);

console.log(fruitWithSixLetters); // Output: 'banana'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using the indexOf Method:&lt;/strong&gt;&lt;br&gt;
The indexOf method returns the index of the first occurrence of a specified element in an array. If the element is not found, it returns -1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [10, 20, 30, 40, 50];

const indexOfThirty = numbers.indexOf(30);

console.log(indexOfThirty); // Output: 2

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using the sort Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The sort method is used to rearrange the elements of an array in place according to their Unicode values. It can take an optional comparison function to specify a custom sorting order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ['banana', 'apple', 'orange', 'grape'];

fruits.sort();

console.log(fruits); // Output: ['apple', 'banana', 'grape', 'orange']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that sort &lt;code&gt;sorts&lt;/code&gt; based on Unicode values, which might not always yield the desired results for numerical or more complex sorting. In such cases, a custom comparison function is essential.&lt;/p&gt;

&lt;p&gt;These array methods allow you to effectively search for specific elements and organize the contents of your arrays. By leveraging these methods, you can make your code more efficient and maintainable when dealing with data manipulation tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Manipulating Arrays with Array Methods
&lt;/h2&gt;

&lt;p&gt;Array methods not only help you retrieve and transform data but also enable you to manipulate arrays by adding, removing, and modifying elements. Let's explore key manipulation methods: &lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, &lt;code&gt;shift&lt;/code&gt;, &lt;code&gt;unshift&lt;/code&gt;, and &lt;code&gt;splice&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. Understanding the Difference and Usage of push and pop Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;push&lt;/code&gt; method adds one or more elements to the end of an array, while the pop method removes the last element from the end of an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stack = [];

stack.push('apple');
stack.push('banana');

console.log(stack); // Output: ['apple', 'banana']

const removedElement = stack.pop();

console.log(removedElement); // Output: 'banana'
console.log(stack); // Output: ['apple']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;II. Why and When to Use the &lt;code&gt;shift&lt;/code&gt; and &lt;code&gt;unshift&lt;/code&gt; Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;shift&lt;/code&gt; method removes the first element from the beginning of an array, and the &lt;code&gt;unshift&lt;/code&gt; method adds one or more elements to the beginning of an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const queue = ['apple', 'banana', 'orange'];

const removedElement = queue.shift();

console.log(removedElement); // Output: 'apple'
console.log(queue); // Output: ['banana', 'orange']

queue.unshift('grape');

console.log(queue); // Output: ['grape', 'banana', 'orange']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;shift&lt;/code&gt; and &lt;code&gt;unshift&lt;/code&gt; can be used to implement a queue-like behavior, where elements are added to the end and removed from the beginning of an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;III. The Importance of Using the splice Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;splice&lt;/code&gt; method allows you to add, remove, or replace elements at a specified index in an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

// Remove elements at index 2 and add 6 and 7
numbers.splice(2, 2, 6, 7);

console.log(numbers); // Output: [1, 2, 6, 7, 5]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;splice&lt;/code&gt; method is versatile and can be used for various array manipulations, such as adding or removing elements at specific positions.&lt;/p&gt;

&lt;p&gt;These manipulation methods provide the tools needed to modify arrays according to your requirements. By utilizing these methods effectively, you can easily control the contents of your arrays to meet your program's needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The Essence of Reduction and Accumulation in JavaScript
&lt;/h2&gt;

&lt;p&gt;The concepts of reduction and accumulation involve processing an array's elements to produce a single value. This is where the reduce method comes into play. Additionally, the &lt;code&gt;reduceRight&lt;/code&gt; method is used to perform the same operation but in reverse order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. Understanding the &lt;code&gt;reduce&lt;/code&gt; Method:&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;reduce&lt;/code&gt; method iterates over an array's elements and accumulates a single value based on a provided callback function. This callback function takes an accumulator and the current element as arguments and returns the updated accumulator. The final value is the result of this accumulation process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

const sum = numbers.reduce((accumulator, currentValue) =&amp;gt; {
  return accumulator + currentValue;
}, 0);

console.log(sum); // Output: 15

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the reduce method calculates the sum of all elements in the numbers array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;II. Why Should You Use the reduceRight Method?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;reduceRight&lt;/code&gt; method is similar to &lt;code&gt;reduce&lt;/code&gt;, but it starts from the last element of the array and iterates towards the first element. This is particularly useful when the order of accumulation matters, such as when processing elements that depend on previous elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const strings = ['a', 'b', 'c'];

const concatenatedString = strings.reduceRight((accumulator, currentValue) =&amp;gt; {
  return accumulator + currentValue;
}, '');

console.log(concatenatedString); // Output: 'cba'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the &lt;code&gt;reduceRight&lt;/code&gt; method concatenates the strings in reverse order, producing the string 'cba'.&lt;/p&gt;

&lt;p&gt;Both &lt;code&gt;reduce&lt;/code&gt; and &lt;code&gt;reduceRight&lt;/code&gt; methods provide a powerful way to accumulate values from an array while applying a custom operation. By harnessing these methods, you can perform complex calculations and data transformations efficiently and elegantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Combining Arrays in JavaScript
&lt;/h2&gt;

&lt;p&gt;Combining arrays is a common operation when you want to merge two or more arrays into a single array. JavaScript offers the &lt;code&gt;concat&lt;/code&gt; method as a simple way to achieve this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the &lt;code&gt;concat&lt;/code&gt; Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;concat&lt;/code&gt; method is used to combine multiple arrays, creating a new array that contains the elements from all the arrays in the order they were provided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const array1 = [1, 2, 3];
const array2 = [4, 5, 6];
const array3 = [7, 8, 9];

const combinedArray = array1.concat(array2, array3);

console.log(combinedArray); // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;concat&lt;/code&gt; method combines the elements from &lt;code&gt;array1&lt;/code&gt;, &lt;code&gt;array2&lt;/code&gt;, and &lt;code&gt;array3&lt;/code&gt; into a single array.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;concat&lt;/code&gt; method doesn't modify the original arrays; it creates a new array that contains the combined elements. This makes it a non-destructive way to merge arrays.&lt;/p&gt;

&lt;p&gt;By utilizing the &lt;code&gt;concat&lt;/code&gt; method, you can easily bring together the contents of multiple arrays without altering the source arrays, making it a valuable tool for array manipulation in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Combining Arrays with the concat Method
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;concat&lt;/code&gt; method in JavaScript allows you to merge two or more arrays into a single array without modifying the original arrays. It's a versatile way to create a new array containing the combined elements from multiple arrays. Let's explore how to use the concat method with code snippets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const array1 = [1, 2, 3];
const array2 = [4, 5, 6];
const array3 = [7, 8, 9];

// Using concat to combine arrays
const combinedArray = array1.concat(array2, array3);

console.log(combinedArray); // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the concat method combines the elements from &lt;code&gt;array1&lt;/code&gt;, &lt;code&gt;array2&lt;/code&gt;, and &lt;code&gt;array3&lt;/code&gt; to create a new array called combinedArray. The order of concatenation is based on the sequence in which the arrays are provided as arguments.&lt;/p&gt;

&lt;p&gt;Combining Arrays with Variables:&lt;/p&gt;

&lt;p&gt;You can also combine arrays stored in variables using the &lt;code&gt;concat&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ['apple', 'banana'];
const vegetables = ['carrot', 'broccoli'];

const combinedFood = fruits.concat(vegetables);

console.log(combinedFood); // Output: ['apple', 'banana', 'carrot', 'broccoli']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Combining Arrays and Values:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The concat method is not limited to arrays; you can also concatenate other values to an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const initialArray = [1, 2, 3];
const newValue = 4;

const newArray = initialArray.concat(newValue);

console.log(newArray); // Output: [1, 2, 3, 4]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By leveraging the &lt;code&gt;concat&lt;/code&gt; method, you can seamlessly merge arrays and values to create new arrays that suit your specific needs, all while keeping your original arrays intact.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Chaining Array Methods in JavaScript
&lt;/h2&gt;

&lt;p&gt;Chaining array methods involves applying multiple array methods one after another on the same array. This technique can lead to concise and expressive code, making complex operations more readable and efficient. Let's delve into the concept of chaining array methods and its benefits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. Understanding Chaining Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Chaining array methods means calling one array method immediately after another on the same array, with each method operating on the result of the previous method. This allows you to perform a series of operations sequentially without creating intermediate arrays or variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

const result = numbers
  .filter(number =&amp;gt; number % 2 === 0) // Filter even numbers
  .map(evenNumber =&amp;gt; evenNumber * 2) // Double each even number
  .reduce((sum, doubledNumber) =&amp;gt; sum + doubledNumber, 0); // Sum the doubled numbers

console.log(result); // Output: 18

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we filter even numbers, double them using &lt;code&gt;map&lt;/code&gt;, and then sum the doubled numbers using &lt;code&gt;reduce&lt;/code&gt;. The chaining of these methods eliminates the need for intermediate arrays and makes the code more streamlined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;II. Benefits of Chaining Method:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Readability: Chaining array methods makes the code more linear and readable. Each method call is aligned vertically, making it easier to understand the sequence of operations.&lt;/p&gt;

&lt;p&gt;Efficiency: Chaining avoids creating intermediate arrays, saving memory and improving performance. This is especially important when dealing with large datasets.&lt;/p&gt;

&lt;p&gt;Expressive Code: Chaining allows you to express complex operations succinctly, making your intentions clear without verbose code.&lt;/p&gt;

&lt;p&gt;Modularity: Chained methods are modular, allowing you to modify or extend operations easily by adding or removing methods in the chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chaining Multiple Operations:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const words = ['apple', 'banana', 'cherry', 'date'];

const result = words
  .filter(word =&amp;gt; word.length &amp;gt; 5) // Filter words with length &amp;gt; 5
  .map(filteredWord =&amp;gt; filteredWord.toUpperCase()) // Convert to uppercase
  .join(', '); // Join into a comma-separated string

console.log(result); // Output: "BANANA, CHERRY"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By chaining array methods, you can create powerful sequences of operations that elegantly manipulate and transform data while maintaining readability and performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, array methods in JavaScript are essential tools that empower developers to efficiently manipulate, transform, and work with arrays. These methods provide a structured and intuitive way to handle a wide range of tasks, from iterating over elements to searching, sorting, and accumulating values. By understanding and utilizing array methods effectively, you can write cleaner, more readable, and more maintainable code. Whether you're a beginner or an experienced programmer, mastering array methods will undoubtedly enhance your ability to work with arrays and streamline your JavaScript programming journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. References:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;MDN Web Docs - Array Methods:&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/frugencefidel/javascript-array-methods-cheatsheet-40df"&gt;JavaScript Array Methods Cheat Sheet:&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/js/js_array_methods.asp"&gt;W3Schools - JavaScript Array Methods:&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://javascript.info/array-methods"&gt;JavaScript.info - Array Methods:&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/the-ultimate-guide-to-javascript-array-methods/"&gt;FreeCodeCamp - The Ultimate Guide to JavaScript Array Methods:&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Chakra UI or Tailwind CSS, Which is the Ultimate choice?</title>
      <dc:creator>Adeeko Tobiloba Isreal</dc:creator>
      <pubDate>Tue, 18 Apr 2023 01:38:48 +0000</pubDate>
      <link>https://dev.to/isreal/chakra-ui-or-tailwind-css-which-is-the-ultimate-choice-326j</link>
      <guid>https://dev.to/isreal/chakra-ui-or-tailwind-css-which-is-the-ultimate-choice-326j</guid>
      <description>&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Are you tired of the same old boring CSS? Are you looking for a way to spice up your UI design without sacrificing &lt;strong&gt;accessibility&lt;/strong&gt; and &lt;strong&gt;performance&lt;/strong&gt;? Look no further, because Tailwind CSS and Chakra UI are here to save the day! These two popular CSS frameworks offer unique approaches to styling your UI components, but which one is the best for your project? In this article, we'll explore the notable differences between Tailwind CSS and Chakra UI, including their &lt;strong&gt;design philosophies, code snippets, and even their build and runtime performance.&lt;/strong&gt; So grab a cup of coffee and get ready to compare and contrast, because it's time to decide which one reigns supreme: Tailwind CSS or Chakra UI!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Now let's get to it!
&lt;/h2&gt;

&lt;p&gt;Tailwind CSS and Chakra UI are two popular UI component libraries that have been widely adopted by developers worldwide. Both have their own set of advantages and disadvantages, but there are some notable core differences between the two. In this article, we will take a closer look at these differences and explore why Chakra UI is the best choice for developers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind CSS&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tailwind CSS is a utility-first CSS framework that focuses on providing pre-defined CSS classes that can be used to style HTML elements. It offers a wide range of classes that can be used to apply styles such as padding, margin, typography, and colors to elements. Developers can use these classes to create complex layouts and styles without writing any CSS code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the main advantages of Tailwind CSS is its flexibility. Since it provides a wide range of pre-defined classes, developers can quickly create custom styles that fit their needs. Additionally, Tailwind CSS is designed to be highly customizable, so developers can configure and extend it to meet their specific requirements.&lt;/p&gt;

&lt;p&gt;Here's an example of how you can use Tailwind CSS to style a button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"&amp;gt;
  Click me
&amp;lt;/button&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're using Tailwind CSS classes to set the background color, text color, font weight, padding, and border radius of the button. This allows us to quickly create a stylish button without writing any vanilla CSS code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chakra UI&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Chakra UI is a component library that provides a set of reusable UI components that can be used to create complex UIs. It focuses on providing a set of high-quality, accessible components that can be used to build responsive, user-friendly interfaces. Chakra UI is built on top of styled-system, a library that provides a set of functions for styling components.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the main advantages of Chakra UI is its accessibility. All components are designed to meet accessibility standards and can be easily customized to meet specific accessibility requirements. Additionally, Chakra UI provides a consistent design system that can be used to create cohesive UIs across different pages and applications.&lt;/p&gt;

&lt;p&gt;Here's an example of how you can use Chakra UI to create a button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Button colorScheme="blue" size="md"&amp;gt;
  Click me
&amp;lt;/Button&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're using the Chakra UI Button component to create a button with a blue color scheme and a medium size. This allows us to quickly create a high-quality, accessible button without writing any CSS code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Chakra UI is the best choice?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While both Tailwind CSS and Chakra UI have their own set of advantages, Chakra UI is the best choice for developers who prioritize accessibility and consistency in their UIs. Chakra UI provides a set of high-quality, accessible components that can be easily customized to meet specific requirements. Additionally, Chakra UI's focus on consistency allows developers to create cohesive UIs across different pages and applications.&lt;/p&gt;

&lt;p&gt;Here's an example of how you can use Chakra UI to create a form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Formik
  initialValues={{ email: '', password: '' }}
  onSubmit={values =&amp;gt; console.log(values)}
&amp;gt;
  &amp;lt;Form&amp;gt;
    &amp;lt;FormControl isRequired&amp;gt;
      &amp;lt;FormLabel&amp;gt;Email address&amp;lt;/FormLabel&amp;gt;
      &amp;lt;Input type="email" name="email" /&amp;gt;
    &amp;lt;/FormControl&amp;gt;
    &amp;lt;FormControl isRequired&amp;gt;
      &amp;lt;FormLabel&amp;gt;Password&amp;lt;/FormLabel&amp;gt;
      &amp;lt;Input type="password" name="password" /&amp;gt;
    &amp;lt;/FormControl&amp;gt;
    &amp;lt;Button mt={4} colorScheme="blue" type="submit"&amp;gt;
      Submit
    &amp;lt;/Button&amp;gt;
  &amp;lt;/Form&amp;gt;
&amp;lt;/Formik&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're using Chakra UI components to create a form that collects an email and password from the user. The Formik component is used to handle form submission and validation, while the Chakra UI Input, FormControl, and FormLabel components are used to create the form fields. The Button component is used to create the form submission button.&lt;/p&gt;

&lt;p&gt;This example demonstrates how easy it is to create complex forms using Chakra UI. The components are designed to work together seamlessly, which makes it easy for developers to create consistent and accessible UIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build and runtime performance&lt;/strong&gt;&lt;br&gt;
When it comes to build and runtime performance, both Tailwind CSS and Chakra UI perform very well. However, there are some differences between the two that are worth noting.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tailwind CSS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Tailwind CSS is a utility-first CSS framework, which means that it generates a lot of CSS classes. This can result in larger CSS files and longer build times, especially if you're using a lot of custom classes. However, Tailwind CSS is designed to be highly customizable, so you can configure it to only include the classes that you need, which can help to reduce the size of your CSS files.&lt;/p&gt;

&lt;p&gt;In terms of runtime performance, Tailwind CSS generates very efficient CSS that is optimized for modern browsers. This means that your pages will load quickly and the user experience will be fast and smooth.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Chakra UI&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Chakra UI is built on top of styled-system, which is a library that uses a theme-based approach to styling components. This means that Chakra UI generates fewer CSS classes than Tailwind CSS, which can result in smaller CSS files and shorter build times. Additionally, Chakra UI provides a set of pre-built themes that you can use to quickly style your components, which can help to reduce the amount of custom CSS that you need to write.&lt;/p&gt;

&lt;p&gt;In terms of runtime performance, Chakra UI generates very efficient CSS that is optimized for modern browsers. Additionally, Chakra UI provides a set of performance optimizations that can help to reduce the amount of work that the browser needs to do when rendering your components. This can result in faster page load times and a smoother user experience.&lt;/p&gt;

&lt;p&gt;The question here now is why i think Chakra is a great choice over tailwind css?&lt;br&gt;
&lt;em&gt;I was opportuned to come accross a blog post of Segun Adebayo which is the author of chakra ui, and i was impressed by some new improvements being incorporated into chakra which i will highlight in this article.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Breaking the monolith&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Chakra UI is a large framework with many different features like components, theming, and styling all tied together. This can make it difficult for developers to understand and contribute to the codebase, leading to longer bug fixing times. To make it easier to work with, we're breaking Chakra UI down into smaller, independent projects that are easier to manage and understand.&lt;br&gt;
To reduce the complexity, we're splitting up the big ideas in Chakra into smaller, manageable and independent projects. Here's a quick overview:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbkdnxz88vec8j05vy3b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbkdnxz88vec8j05vy3b.jpg" alt="Chakra UI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This image better explains the architecture they're willing to achieve with chakra.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'll be talking about the architecture of this image in this section in simple words.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Styled System(zero runtime css-in-js[Panda]):&lt;/strong&gt; Developers love using style props and runtime CSS-in-JS to create dynamic UI components that are easy to use. However, these features can slow down the performance of the application. To solve this problem, we're building a new styling solution called Panda that will extract styles at build time, which means the application will run faster. Panda will also use new platform features like CSS variables and cascade layers to make styling even easier for developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;State Machine + Accessibilty (using zag):&lt;/strong&gt; Chakra UI is designed to make interactive components easy to use, no matter what framework you're using. We achieve this by modeling every component as a state machine. This means that we carefully plan out how the component will change and behave in different states, making it predictable and easy to maintain. By using this approach, we can create components that are easy to debug and understand, which will ultimately make your development process smoother.&lt;/p&gt;

&lt;p&gt;Here is an example of how to build a number input component using zag in react.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // 1. Import the state machine
  import * as numberInput from '@zag-js/number-input';

  // 2. Import the React bindings
  import { useMachine, normalizeProps } from '@zag-js/react';

  export function NumberInput() {
    // 3. Consume the machine
    const [state, send] = useMachine(numberInput.machine({ id: '1', max: 50, min: -50 }));

    // 4. Convert machine to a user friendly API
    const api = numberInput.connect(state, send, normalizeProps);

    // 5. Render the component
    return (
      &amp;lt;div {...api.rootProps}&amp;gt;
        &amp;lt;label {...api.labelProps}&amp;gt;Enter number:&amp;lt;/label&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;button {...api.decrementButtonProps}&amp;gt;DEC&amp;lt;/button&amp;gt;
          &amp;lt;input {...api.inputProps} /&amp;gt;
          &amp;lt;button {...api.incrementButtonProps}&amp;gt;INC&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Isn't this a great leap that you can manage your states and also make them reuseable accross &lt;br&gt;
  components?&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Zag.js is our low-level state machine library used to build all the components in Chakra &lt;br&gt;
  UI. We aim to develop a robust set of application and e-commerce components that works in &lt;br&gt;
  most JS frameworks.&lt;br&gt;
  &lt;strong&gt;&lt;em&gt;To learn more about Zag.js, check out the docs here: &lt;a href="https://zagjs.com" rel="noopener noreferrer"&gt;https://zagjs.com&lt;/a&gt;, or you can watch &lt;br&gt;
  my demo on the Learn with Jason show here: &lt;a href="https://www.youtube.com/watch?v=l8HJoE_ktDc" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=l8HJoE_ktDc&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Headless Components:&lt;/strong&gt; Building UI components with State machines sounds exciting but can sometimes sound complex or scary. It sometimes gives the impression that you need to know, or at least learn, about state machines before you can use them. That's not the case (at all).&lt;/p&gt;

&lt;p&gt;To increase adoption, we're wrapping Zag.js component logic into a headless component library you can use to build your applications and design systems with speed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NumberInput } from '@ark-ui/react';

export function Demo() {
  return (
    &amp;lt;NumberInput min={-50} max={50}&amp;gt;
      &amp;lt;NumberInput.Label&amp;gt;Label&amp;lt;/NumberInput.Label&amp;gt;
      &amp;lt;NumberInput.Field /&amp;gt;
      &amp;lt;NumberInput.Control&amp;gt;
        &amp;lt;NumberInput.DecrementTrigger&amp;gt;
          &amp;lt;button&amp;gt;-1&amp;lt;/button&amp;gt;
        &amp;lt;/NumberInput.DecrementTrigger&amp;gt;
        &amp;lt;NumberInput.IncrementTrigger&amp;gt;
          &amp;lt;button&amp;gt;+1&amp;lt;/button&amp;gt;
        &amp;lt;/NumberInput.IncrementTrigger&amp;gt;
      &amp;lt;/NumberInput.Control&amp;gt;
    &amp;lt;/NumberInput&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Chakra team created a new library called Ark, which will be the headless component foundation for Chakra UI.&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;It's open source and you can check it out here: &lt;a href="https://github.com/chakra-ui/ark" rel="noopener noreferrer"&gt;https://github.com/chakra-ui/ark&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Design token platform [Ultra]:&lt;/strong&gt; Design tokens are quickly becoming the standard for managing design decisions in a product or website today. They're a powerful concept that allows you to build a design system that is flexible, scalable, and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chakra UI today supports a theming system that allows you to customize design tokens and components at any level of granularity. We also added basic support for semantic tokens to enable developers to build automatic light and dark modes into their applications. Most enterprise applications require more than just light and dark modes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Beyond authoring design tokens, transforming and distributing tokens to different platforms and projects is a huge pain point for most design systems.&lt;/p&gt;

&lt;p&gt;We're building Ultra, a SaaS platform that will allow product teams:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create core and semantic design tokens visually (without it feeling like grunt work)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define best practices, shared layers and text styles across your project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides automatic documentation for your tokens with a GPT interface for searching and filtering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distribute design tokens to different platforms and project&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion this particular framework &lt;strong&gt;Chakra UI&lt;/strong&gt; has a great potential amongst its peers. It seems like a no-brainer to get inclined and familiar with its concept and use it to achieve efficiency and speed in styling your product. I mean isn't that what we've always wanted to achieve as developer? &lt;strong&gt;Speed and Efficiency&lt;/strong&gt;, in which chakra will be serving on a platter of Gold.&lt;/p&gt;

&lt;p&gt;To read more on the chakra latest updates you can check through this link: &lt;a href="https://www.adebayosegun.com/blog/the-future-of-chakra-ui" rel="noopener noreferrer"&gt;https://www.adebayosegun.com/blog/the-future-of-chakra-ui&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this is helpful drop a like and also your comments and criticism are welcomed. &lt;/p&gt;

</description>
      <category>css</category>
      <category>tailwindcss</category>
      <category>chakraui</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Fetch and Write data into firestore cloud. Beginners Guide.</title>
      <dc:creator>Adeeko Tobiloba Isreal</dc:creator>
      <pubDate>Thu, 13 Apr 2023 16:07:56 +0000</pubDate>
      <link>https://dev.to/isreal/how-to-fetch-and-write-data-into-firestore-cloud-beginners-guide-4jce</link>
      <guid>https://dev.to/isreal/how-to-fetch-and-write-data-into-firestore-cloud-beginners-guide-4jce</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Are you tired of keeping your data scattered across multiple platforms and devices? Do you want to streamline your data management process and access all your information in one place? Look no further than Firestore Cloud! With Firestore, you can easily store and manage your data in the cloud, and access it from anywhere at any time. In this beginner's guide, we'll show you how to fetch and write data into Firestore Cloud, step-by-step.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Table of content&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setup Firebase for your project.&lt;/li&gt;
&lt;li&gt;Setup your react project&lt;/li&gt;
&lt;li&gt;Connect and Initialize Firebase to your project&lt;/li&gt;
&lt;li&gt;Create Firestore Database in your firebase console.&lt;/li&gt;
&lt;li&gt;Write data to your firestore cloud&lt;/li&gt;
&lt;li&gt;Read data from your firestore cloud&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Setup Firebase for your project: This is one of the most crucial yet basic part of setting up your firebase console for your application. So in other to make things easy. I'll walking you through images of each step on how to setup firebase console for your application.&lt;/p&gt;

&lt;p&gt;step 1: Go to &lt;a href="https://firebase.google.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Firebase Link&lt;/strong&gt;&lt;/a&gt;. Sign up and login to firebase. So that your console can be created.&lt;/p&gt;

&lt;p&gt;step 2: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewr452ezh3zk7yi9v37v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewr452ezh3zk7yi9v37v.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now that you have your console setup. You can proceed to click on the &lt;strong&gt;Add Project&lt;/strong&gt; box to get started with initiating your project.&lt;/p&gt;

&lt;p&gt;step 3: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6z28o28e87hd3z97sl9f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6z28o28e87hd3z97sl9f.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
As shown in the image follow the prompt by adding the name of the project you chose. As for me &lt;strong&gt;attendance-app&lt;/strong&gt; works fine.&lt;/p&gt;

&lt;p&gt;step 4: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrxjhxa2mnq4vdp14ro4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrxjhxa2mnq4vdp14ro4.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
So this page explains the features you'll be getting on your console for free. Nothing much to see here though. Just to fulfill all righteousness i gotta include it. Click &lt;strong&gt;continue&lt;/strong&gt; let's get on with this 😎.&lt;/p&gt;

&lt;p&gt;step 5: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbxpevh6xnh1z9iimfkj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbxpevh6xnh1z9iimfkj.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click the dropdown and select the &lt;strong&gt;Default account for firebase&lt;/strong&gt; then continue.&lt;/p&gt;

&lt;p&gt;step 6: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqvrd1vnm0tqd6egwk13.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqvrd1vnm0tqd6egwk13.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Cool.. We're getting very close to the cool stuff. Our app console has been successfully created on firebase.&lt;/p&gt;

&lt;p&gt;Not assuming you already have a project setup yet. &lt;br&gt;
You can easily setup your react project by using this command in your terminal&lt;br&gt;
 &lt;code&gt;npx create-react-app attendance-app&lt;/code&gt;. There are other frameworks out there that you can also use to with firebase. Which are Vuejs, Nextjs, Angularjs... and any other frontend framework you know about. Its not quantum physics to set firebase up with any of them, pretty much similar steps to follow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this article we're going to be using a react project.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;After creating your application in your terminal.&lt;br&gt;
Navigate to the folder in which you have created your project and open it in vscode or which ever IDE  you're using. My favorite is Vscode though.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;Setup your react project: Now take a sneak peak of the folder structure of one of the react projects. I'm working on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29yumqaphxvoiaz03aaw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29yumqaphxvoiaz03aaw.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
In this image you'll notice there is a &lt;strong&gt;firebase.js&lt;/strong&gt; file in there. Yes this is where firebase is being connected to your project. To get started on that you have to follow these steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to your firebase console.&lt;/li&gt;
&lt;li&gt;Click on the settings icon next to Project Overview on the left pane of your firebase console dashboard.&lt;/li&gt;
&lt;li&gt;Click on project settings and scroll to the bottom of the page. You'll find a detailed set on how to add firebase to your project.&lt;/li&gt;
&lt;li&gt;Open your terminal and navigate to your project directory.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;npm install firebase&lt;/code&gt; to have it installed in your project.&lt;/li&gt;
&lt;li&gt;Then create a &lt;strong&gt;firebase.js&lt;/strong&gt; file. &lt;/li&gt;
&lt;li&gt;Add this code in the firebase file.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
 //TODO: Add SDKs for Firebase products that you want to use
 //https://firebase.google.com/docs/web/setup#available-libraries`

 //Your web app's Firebase configuration
 //For Firebase JS SDK v7.20.0 and later, measurementId is optional
 const firebaseConfig = {
  apiKey: "******************************",
  authDomain: "******************************.firebaseapp.com",
  projectId: "attendance-app-******************************,
  storageBucket: "******************************.appspot.com",
  messagingSenderId: "***********",
  appId: "1:******************************",
  measurementId: "******************************"
  };

  //Initialize Firebase
  const app = initializeApp(firebaseConfig);
  const analytics = getAnalytics(app);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You'll find the necessary data i excluded from this code block in your firebase console.&lt;/p&gt;

&lt;p&gt;Create Firestore Database in your firebase console: To do these we'll be going through another set of graphics to better visualize our steps.&lt;br&gt;
a. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F901w9dtpdjqbpx4x05ln.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F901w9dtpdjqbpx4x05ln.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
..Click on build on the left panel&lt;br&gt;
..Click on Firestore Database as highlighted in the image above.&lt;br&gt;
..Click on the create database button, then you'll be prompted to setup in production in a modal.&lt;br&gt;
..Click on the closest location to you and hit continue button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6op1bvnu01a5057uhg9c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6op1bvnu01a5057uhg9c.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you'll have a view of your database.&lt;br&gt;
Kindly read up on firestore rules as you might need it for specific functions in your database. &lt;a href="https://firebase.google.com/docs/rules/get-started?hl=en&amp;amp;authuser=0" rel="noopener noreferrer"&gt;&lt;strong&gt;Firestore Rules&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing Data to your database Firestore&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly you have to reference the database in any file you want to initialize the write data function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getDatabase } from "firebase/database";

const database = getDatabase();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function below allows you to write data into your firestore database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getDatabase, ref, set } from "firebase/database";

function writeUserData(userId, name, email, imageUrl) {
  const db = getDatabase();
  set(ref(db, 'users/' + userId), {
    username: name,
    email: email,
    profile_picture : imageUrl
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reading Data from your database Firestore&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly you have to reference the database in any file you want to initialize the read data function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getDatabase } from "firebase/database";

const database = getDatabase();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getDatabase, ref, child, get } from "firebase/database";

const dbRef = ref(getDatabase());
get(child(dbRef, `users/${userId}`)).then((snapshot) =&amp;gt; {
  if (snapshot.exists()) {
    console.log(snapshot.val());
  } else {
    console.log("No data available");
  }
}).catch((error) =&amp;gt; {
  console.error(error);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also read the firebase documentation for your reference. &lt;a href="https://firebase.google.com/docs/database/web/read-and-write?hl=en&amp;amp;authuser=0" rel="noopener noreferrer"&gt;https://firebase.google.com/docs/database/web/read-and-write?hl=en&amp;amp;authuser=0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for going this far. Like and drop comments if this was helpful, and i'm open to questions or constructive criticism. &lt;/p&gt;

&lt;p&gt;Have a bug-filled day 😃&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Fixing baseURL error in Nextjs-auth0</title>
      <dc:creator>Adeeko Tobiloba Isreal</dc:creator>
      <pubDate>Mon, 01 Aug 2022 02:27:10 +0000</pubDate>
      <link>https://dev.to/isreal/fixing-baseurl-error-in-nextjs-auth0-58n4</link>
      <guid>https://dev.to/isreal/fixing-baseurl-error-in-nextjs-auth0-58n4</guid>
      <description>&lt;p&gt;Contrary to the YouTube tutorial and auth0 documentation that I followed diligently while setting up my code of nextjs and auth0 authentication, still i encountered this error and it took awhile to find a solution to fix the error. &lt;em&gt;&lt;code&gt;Talk is cheap show me the code.&lt;/code&gt;&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;👾 &lt;strong&gt;Let’s dive right into fixing the error.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error image.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KxtJ1XM8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/948mr6hrn03qbr2fv47v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KxtJ1XM8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/948mr6hrn03qbr2fv47v.png" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you’re getting this exact error then i have the exact fix for you in this article.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your _app.js you should import UserProvider and wrap it around the component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../styles/globals.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;UserProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@auth0/nextjs-auth0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pageProps&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;UserProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;pageProps&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;UserProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step One:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you have your .env.local file created in the root of your app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aBVMXw-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7dh7ugekaevl3yc3hlx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aBVMXw-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7dh7ugekaevl3yc3hlx.jpg" alt="Image description" width="403" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step Two:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The contents of you .env.local file should be arranged in this format.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;AUTH0_SECRET='random generated number'&lt;br&gt;
AUTH0_BASE_URL='http://localhost:3000'&lt;br&gt;
AUTH0_ISSUER_BASE_URL='https://YOUR_DOMAIN_AUTH0_DASHBOARD'&lt;br&gt;
AUTH0_CLIENT_ID='CLIENT_ID_AUTH0_DASHBOARD'&lt;br&gt;
AUTH0_CLIENT_SECRET='CLIENT_SECRET_AUTH0_DASHBOARD'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step Three:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your pages/api/auth/[…auth0].js file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pages/api/auth/[...auth0].js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;handleAuth&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@auth0/nextjs-auth0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;handleAuth&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AUTH0_BASE_URL&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the file where the error comes from.&lt;/p&gt;

&lt;p&gt;Contrary to what is in the auth0 documentation for nextjs which is the snippet below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;handleAuth&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@auth0/nextjs-auth0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;handleAuth&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will definitely throw an error because the handleauth isn’t able to read the baseUrl from the env.local file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step Four:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The last step is to navigate to the authentication url in your browsers’ url.&lt;/p&gt;

&lt;p&gt;Add the api/auth/login to your &lt;a href="http://localhost"&gt;localhost&lt;/a&gt; url&lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;api/auth/login&lt;/p&gt;

&lt;p&gt;If this helped solve the error you’ll get this in your browser’s &lt;a href="http://localhost:3000/api/auth/login"&gt;http://localhost:3000/api/auth/login&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KksVSZ5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2b97paiqudvmg4xaahl2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KksVSZ5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2b97paiqudvmg4xaahl2.jpg" alt="Image description" width="880" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😜 &lt;strong&gt;Finally! Problem solved.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If this helped follow my twitter handle @celebrity_dev&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>auth0</category>
    </item>
  </channel>
</rss>
