<?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>Forem: MILIND D JAIN</title>
    <description>The latest articles on Forem by MILIND D JAIN (@jmilind1234).</description>
    <link>https://forem.com/jmilind1234</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%2F1167018%2Fd0a668a6-f48e-4ba7-bcc5-8c45811cda9e.jpeg</url>
      <title>Forem: MILIND D JAIN</title>
      <link>https://forem.com/jmilind1234</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jmilind1234"/>
    <language>en</language>
    <item>
      <title>Database connection in NextJS (App Router)</title>
      <dc:creator>MILIND D JAIN</dc:creator>
      <pubDate>Sun, 04 Jan 2026 16:50:06 +0000</pubDate>
      <link>https://forem.com/jmilind1234/database-connection-in-nextjs-app-router-3aoe</link>
      <guid>https://forem.com/jmilind1234/database-connection-in-nextjs-app-router-3aoe</guid>
      <description>&lt;p&gt;In today's post, we will be learning about the good way of connecting the NextJS application to the database via PrismaORM.&lt;/p&gt;

&lt;p&gt;For those who are new to Prisma ORM, here is the quick gist of it. Prisma  ORM ( Object Relational Mapping) is the tool that makes communication with the database easy. So, let's say you want to connect to any database, be it MySQL, PostgreSQL, SQLite, or MongoDB, then the straightway is to write a query that is understood by the database we are using.&lt;/p&gt;

&lt;p&gt;Now, this way is not wrong, but it gives rise to many problems like - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The developer needs to know the proper syntax for the query 😟.&lt;/li&gt;
&lt;li&gt;A small mistake can take hours to debug.&lt;/li&gt;
&lt;li&gt;More vulnerable to errors, which in turn makes switching to a different database difficult.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ORM / ODM are saviours here, they work as the middle translator between the database and our application. So, no need to worry about the actual syntax of the database we want to use.&lt;/p&gt;

&lt;p&gt;Now, let's talk about a good way of connecting the Prisma client for database connection in the NextJS app router. Here is the code, followed by the explanation in brief detail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { PrismaClient } from "@/generated/prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";

const globalForPrisma = globalThis as unknown as {
  prisma: PrismaClient | undefined;
};

const connectionString = `${process.env.DATABASE_URL}`;

const adapter = new PrismaPg({connectionString});

export const prisma = globalForPrisma.prisma || new PrismaClient({adapter});


if(process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;

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

&lt;/div&gt;



&lt;p&gt;Creating a prisma client and connecting to the database can be done in 2 to 3 lines, but why so much of surrounded code? Here is the reason - &lt;/p&gt;

&lt;p&gt;Let's say when we deploy our NextJS application, then it is not like we have only one instance, but it is loaded to multiple instances. Means multiple instances are already sitting to handle traffic, but that does not mean we have that many db connections.&lt;/p&gt;

&lt;p&gt;Whenever a user hits the application from the browser, that request creates a new db connection on the instance it hits. Now, if another request comes to that same instance, then via module caching creation of a new Prisma client is prevented. &lt;/p&gt;

&lt;p&gt;But in the case of a non-prod environment, like development, we have hot-reloading, hence to prevent db connection on each hot reload, we use a global store to cache it.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>database</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>All about routing in react (Part 2) ft. react-router-dom</title>
      <dc:creator>MILIND D JAIN</dc:creator>
      <pubDate>Sun, 10 Mar 2024 16:23:28 +0000</pubDate>
      <link>https://forem.com/jmilind1234/all-about-routing-in-react-part-2-ft-react-router-dom-2ecn</link>
      <guid>https://forem.com/jmilind1234/all-about-routing-in-react-part-2-ft-react-router-dom-2ecn</guid>
      <description>&lt;p&gt;This post is sequel of my previous post on the routing on react.&lt;br&gt;
Please check that before following this,&lt;br&gt;
"&lt;a href="https://dev.to/jmilind1234/all-about-routing-in-react-part-1-ft-react-router-dom-2fd1"&gt;https://dev.to/jmilind1234/all-about-routing-in-react-part-1-ft-react-router-dom-2fd1&lt;/a&gt;".&lt;br&gt;
In my previous post I wrote about how to create the routing configuration and difference between server-side-routing and client-side-routing.&lt;/p&gt;

&lt;p&gt;Now here, we are going to see about the following topics - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;children routes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;getting error information in navigation and showing custom error page.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, let start with children routes. These are also referred as nested routes. Lets, say we have 3 routes as "/", "/about", "/contact" and we want that these 3 pages share same layout, means to say all have same header, footer, sidebar etc. &lt;br&gt;
So, one way is that we create router configuration as we did and on each page we call header, footer and sidebar with page specific component. &lt;/p&gt;

&lt;p&gt;This is fine, it will work. &lt;/p&gt;

&lt;p&gt;But not smart way. Smart way is to define paths inside children of the "/". Lets see a code example for same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;appRouter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;createBrowserRouter&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AppLayout&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;errorElement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;Error&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Body&lt;/span&gt; &lt;span class="o"&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="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="o"&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="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt; &lt;span class="o"&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="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/restaurant/:resId&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;element&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RestaurantMenu&lt;/span&gt;&lt;span class="o"&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="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Here, for "/" path we have mentioned element, that's basically defines layout for its children routes, errorElement defines what to show if we try to access undefined route. We have also used children prop, that is a place where all nested routes are defined, like for "/" we will show &lt;code&gt;&amp;lt;Body/&amp;gt;&lt;/code&gt; component and similarly for other 3.&lt;/p&gt;

&lt;p&gt;But wait, how and where &lt;code&gt;&amp;lt;About/&amp;gt;&lt;/code&gt; will come and layout will be shared. &lt;/p&gt;

&lt;p&gt;Well here comes the powerful &lt;code&gt;&amp;lt;Outlet/&amp;gt;&lt;/code&gt; component that comes from react-router-dom package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AppLayout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Outlet&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, for "/about" path, &lt;code&gt;&amp;lt;Outlet/&amp;gt;&lt;/code&gt; will be replaced by &lt;code&gt;&amp;lt;About/&amp;gt;&lt;/code&gt; and same for rest 3. Here, &lt;code&gt;&amp;lt;Header/&amp;gt;&lt;/code&gt; will be shared by all the children routes.&lt;/p&gt;

&lt;p&gt;This was all about nested routes or children routes and how layout is shared and power of &lt;code&gt;&amp;lt;Outlet/&amp;gt;&lt;/code&gt; component.&lt;/p&gt;

&lt;p&gt;Now lets begin with custom error page and how to get navigation error information.&lt;/p&gt;

&lt;p&gt;First part we already covered while creating routing configuration ( remember - errorElement).&lt;/p&gt;

&lt;p&gt;To get the navigation error information, we have a hook "useRouteError", this also comes from "react-router-dom".&lt;/p&gt;

&lt;p&gt;In my next post, we will study about query params and route params. &lt;/p&gt;

&lt;p&gt;Thanks for reading the post.😊&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>router</category>
    </item>
    <item>
      <title>All about routing in React (Part 1) ft. react-router-dom</title>
      <dc:creator>MILIND D JAIN</dc:creator>
      <pubDate>Fri, 08 Mar 2024 07:23:29 +0000</pubDate>
      <link>https://forem.com/jmilind1234/all-about-routing-in-react-part-1-ft-react-router-dom-2fd1</link>
      <guid>https://forem.com/jmilind1234/all-about-routing-in-react-part-1-ft-react-router-dom-2fd1</guid>
      <description>&lt;p&gt;Here, in this post we are going to learn about the routing in react applications using react-router-dom v6.&lt;/p&gt;

&lt;p&gt;React-router-dom is a powerful library that is used to handle the routing mechanism in the react application. Its special because in addition to routing it also provides the way to achieve client-side-routing instead of server-side-routing.&lt;/p&gt;

&lt;p&gt;Before getting to point on how it provides the client-side-routing, lets discuss in short about client-side-routing and server-side-routing.&lt;/p&gt;

&lt;p&gt;So basically in old web apps where hyperlinks (to navigate to other pages) were mentioned using anchor tag, used to make the request to the server and server used to send the page data in response. Even if in react we use anchor tags to navigate we can see that as we click on hyperlinks it will make a request to server and server will return the landing page of our app (where a div with id root is placed), and browser will paint on to that page.&lt;br&gt;
Such kind of routing is called server-side-routing.&lt;/p&gt;

&lt;p&gt;Now, another comes client-side-routing, where for getting the content of new page (page to which we want to land), webapp will not make a request to the server.&lt;/p&gt;

&lt;p&gt;So how and from where that page content will come from? 🤔&lt;br&gt;
Well in react when we first time hit the domain of our app, all the components are loaded. And these already loaded components will be only served when we navigate to page. Simple !!!&lt;/p&gt;

&lt;p&gt;This was about the two types of routing that is used across all web apps.&lt;/p&gt;

&lt;p&gt;Now, lets discuss on about "how to start with react-router-dom, to handle routing?"&lt;/p&gt;

&lt;p&gt;So, to start with routing we first need to convey our react app all important information about routes and what to show.&lt;/p&gt;

&lt;p&gt;This is done by creating routing configuration and wrap our whole app with this routing configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&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;Outlet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createBrowserRouter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useLocation&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;react-router-dom&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;appRouter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;createBrowserRouter&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AppLayout&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;errorElement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;Error&lt;/span&gt; &lt;span class="o"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="o"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt; &lt;span class="o"&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="p"&gt;]);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;So, here basically we mentioned -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Number of routes.&lt;/li&gt;
&lt;li&gt;Path of routes.&lt;/li&gt;
&lt;li&gt;Component to display on each route.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember - if component is missed than &lt;code&gt;&amp;lt;Outlet/&amp;gt;&lt;/code&gt; will be rendered, which is by default null (means a white screen)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But this is not enough, because still our app is not aware about the paths or routes. To make our app aware about routes and what to show for each path, we need to wrap whole app inside the router provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&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;RouterProvider&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;react-router-dom&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="nx"&gt;AppLayout&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;./src/AppLayout&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="nx"&gt;ReactDOM&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;react-dom/client&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;appRouter&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;./src/AppLayout&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RouterProvider&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;appRouter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AppLayout&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/RouterProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This AppLayout is the starting point of our react-app. &lt;/p&gt;

&lt;p&gt;Now our app is aware about all the routes. 🚀&lt;/p&gt;

&lt;p&gt;This was about basic routing, but lets say if requested path is not aware than? What to show? How to handle?&lt;br&gt;
No worries, errorElement will take care of it.&lt;/p&gt;

&lt;p&gt;In the next post/article we will resume about nested routes, dynamic routing etc. 😊&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactrouterdom</category>
      <category>javascript</category>
      <category>javascriptlibraries</category>
    </item>
  </channel>
</rss>
