T
TanStack2mo ago
correct-apricot

Route layout rendering

I have made my whole app by default ssr false
export function createRouter() {
if (posthog && typeof window !== "undefined") {
posthog.init(import.meta.env.VITE_POSTHOG_KEY, {
api_host: import.meta.env.VITE_POSTHOG_HOST,
});
}
return routerWithQueryClient(
createTanStackRouter({
routeTree,
context: { queryClient },
// defaultPreload: 'intent',
defaultErrorComponent: () => <div>Error</div>,
defaultNotFoundComponent: () => <div>Not Found</div>,
defaultSsr: false,
}),
queryClient,
);
}
export function createRouter() {
if (posthog && typeof window !== "undefined") {
posthog.init(import.meta.env.VITE_POSTHOG_KEY, {
api_host: import.meta.env.VITE_POSTHOG_HOST,
});
}
return routerWithQueryClient(
createTanStackRouter({
routeTree,
context: { queryClient },
// defaultPreload: 'intent',
defaultErrorComponent: () => <div>Error</div>,
defaultNotFoundComponent: () => <div>Not Found</div>,
defaultSsr: false,
}),
queryClient,
);
}
import { BottomNavigation } from "@/components/bottom-bars/bottom-navigation";
import { Navigation } from "@/components/headers/app-navigation";
import { AppSidebar } from "@/components/sidebars/app-sidebar";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { useAuth } from "@/hooks/use-auth";
import { useIsMobile } from "@/hooks/use-mobile";
import { createFileRoute, Outlet } from "@tanstack/react-router";

export const Route = createFileRoute("/app")({
component: RouteComponent,
loader: async ({ location }) => {
return location.pathname;
},
ssr: false,
});

const NAVIGATION_ROUTE_MATCH = [
"/app",
"/app/chats",
"/app/websites",
"/app/workflows",
];

function RouteComponent() {
const currentPath = Route.useLoaderData();
const isMobile = useIsMobile();
const { user } = useAuth();
console.log("Reasdf", user);
return (
<SidebarProvider defaultOpen={false}>
<AppSidebar />
<SidebarInset className="overflow-auto">
{NAVIGATION_ROUTE_MATCH.includes(currentPath) && (
<Navigation />
)}
<Outlet />
{NAVIGATION_ROUTE_MATCH.includes(currentPath) && isMobile && (
<BottomNavigation />
)}
</SidebarInset>
</SidebarProvider>
);
}
import { BottomNavigation } from "@/components/bottom-bars/bottom-navigation";
import { Navigation } from "@/components/headers/app-navigation";
import { AppSidebar } from "@/components/sidebars/app-sidebar";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { useAuth } from "@/hooks/use-auth";
import { useIsMobile } from "@/hooks/use-mobile";
import { createFileRoute, Outlet } from "@tanstack/react-router";

export const Route = createFileRoute("/app")({
component: RouteComponent,
loader: async ({ location }) => {
return location.pathname;
},
ssr: false,
});

const NAVIGATION_ROUTE_MATCH = [
"/app",
"/app/chats",
"/app/websites",
"/app/workflows",
];

function RouteComponent() {
const currentPath = Route.useLoaderData();
const isMobile = useIsMobile();
const { user } = useAuth();
console.log("Reasdf", user);
return (
<SidebarProvider defaultOpen={false}>
<AppSidebar />
<SidebarInset className="overflow-auto">
{NAVIGATION_ROUTE_MATCH.includes(currentPath) && (
<Navigation />
)}
<Outlet />
{NAVIGATION_ROUTE_MATCH.includes(currentPath) && isMobile && (
<BottomNavigation />
)}
</SidebarInset>
</SidebarProvider>
);
}
but still my route.tsx is rendering in ssr the console log is not being printed here after updating the user
3 Replies
fascinating-indigo
fascinating-indigo2mo ago
which version are you on? try with latest
correct-apricot
correct-apricotOP2mo ago
"@tanstack/react-start": "^1.125.0", I am using this version of tanstack start
fascinating-indigo
fascinating-indigo2mo ago
hm should work can you provide a complete example repo?

Did you find this page helpful?