T
TanStackโ€ข3w ago
equal-aqua

๐Ÿ’ก Need Help with TanStack Router Layouts

Hey everyone ๐Ÿ‘‹ Iโ€™m working on a React project with TypeScript and TanStack Router, and Iโ€™m a bit stuck with creating two different layouts. ๐Ÿ‘‰ Hereโ€™s the setup I want: - Main Layout โ†’ Navbar + Footer + <Outlet /> (for public pages like About, Pricing, Contact). - Dashboard Layout โ†’ A totally different layout (no Navbar/Footer from the root). It should have a Sidebar (on the left) and a small navbar/header (just for Logo or Settings). The dashboard pages (like Manage Users, Add Money, etc.) should be displayed on the right side. The issue: My main layout works fine with Navbar/Footer. But when I click the Dashboard link after login, I want the layout to switch to the Dashboard layout. Basically: /about, /pricing, /contactโ†’ Use Main Layout /dashboard/* โ†’ Use Dashboard Layout (completely separate from the root Navbar/Footer). โ“ My Question: Whatโ€™s the best way to structure this in TanStack Router? How do you usually set up multiple layouts (like __root.tsx for public pages and a separate __layout.tsx for dashboard)? Thanks in advance ๐Ÿ™
7 Replies
mere-teal
mere-tealโ€ข3w ago
Hi Where are you from?
equal-aqua
equal-aquaOPโ€ข3w ago
Bangladesh @Come on Cat! and you?
mere-teal
mere-tealโ€ข3w ago
Zagreb, Croatia
equal-aqua
equal-aquaOPโ€ข3w ago
Greate, do you have any idea about my post?
mere-teal
mere-tealโ€ข3w ago
Can you show me your project?
correct-apricot
correct-apricotโ€ข3w ago
Hello Sumon here is an example that I've set up for one of my projects that works well
No description

Did you find this page helpful?