<?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: Reza Baharvand</title>
    <description>The latest articles on Forem by Reza Baharvand (@rezabaharvand).</description>
    <link>https://forem.com/rezabaharvand</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%2F1827042%2Fb42286ad-5387-43a6-aefe-a27562634e22.png</url>
      <title>Forem: Reza Baharvand</title>
      <link>https://forem.com/rezabaharvand</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rezabaharvand"/>
    <language>en</language>
    <item>
      <title>How Layout Management works in Next.js App Router: Shared and Stand-Alone Approaches</title>
      <dc:creator>Reza Baharvand</dc:creator>
      <pubDate>Tue, 23 Jul 2024 17:10:20 +0000</pubDate>
      <link>https://forem.com/rezabaharvand/how-layout-management-works-in-nextjs-app-router-shared-and-stand-alone-approaches-1nn</link>
      <guid>https://forem.com/rezabaharvand/how-layout-management-works-in-nextjs-app-router-shared-and-stand-alone-approaches-1nn</guid>
      <description>&lt;p&gt;Recently, I migrated to Next.js's new App Router and explored using a different layout for ad landing pages. Unlike the rest of my application, these pages needed unique navigation. With Next.js, you can now name directories with parentheses &lt;code&gt;()&lt;/code&gt; which won't affect the routing. This approach isn't my preferred method for managing layouts, but it does help in keeping the application folders well-organized.&lt;/p&gt;

&lt;p&gt;For example, I can have separate folders for my dashboard, app, website, blog, and landing pages, enhancing overall structure. Since I use MDX and need specific compilation settings, ensuring that functions correctly reference these new directories was crucial.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/nAa7RNNzhwk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./src/app
├── &lt;span class="o"&gt;(&lt;/span&gt;lp&lt;span class="o"&gt;)&lt;/span&gt;
│   ├── layout.tsx -&amp;gt; Layout &lt;span class="k"&gt;for &lt;/span&gt;all landing pages
│   └── special-offer
│       └── page.tsx -&amp;gt; Special Offer page
├── &lt;span class="o"&gt;(&lt;/span&gt;website&lt;span class="o"&gt;)&lt;/span&gt;
│   ├── about
│   │   └── page.tsx -&amp;gt; About page
│   ├── layout.tsx -&amp;gt; Layout &lt;span class="k"&gt;for &lt;/span&gt;all website pages
│   └── page.tsx -&amp;gt; Homepage
├── favicon.ico
├── globals.css
└── layout.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;layout.tsx&lt;/code&gt; in the root is globally shared.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;layout.tsx&lt;/code&gt; under &lt;code&gt;(website)&lt;/code&gt; affects only pages in that folder.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;layout.tsx&lt;/code&gt; under &lt;code&gt;(lp)&lt;/code&gt; is exclusive to pages in that landing page folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This setup lets each section of the application maintain its thematic consistency while still sharing some global components.&lt;/p&gt;




&lt;p&gt;You can connect with me on my &lt;a href="https://rezabaharvand.dev" rel="noopener noreferrer"&gt;personal website&lt;/a&gt; or see my work on &lt;a href="https://blueboost.co" rel="noopener noreferrer"&gt;Blue Boost&lt;/a&gt; and &lt;a href="https://authorityroadmap.com" rel="noopener noreferrer"&gt;Authority Roadmap&lt;/a&gt;.&lt;/p&gt;

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