TanStackT
TanStack10mo ago
6 replies
verbal-lime

Getting access to parent route data in child route loader

using file-based router, how would you get access in a child route loader, to the parent route data (loader) i.e
const parentRoute = createFileRoute('/dashboard')({
  loader: async () => {
    const data = await fetch('....')
    return data;
  },
  component: () => <Outlet />, // Ensure child routes can render here
});
`

const childRoute = createFileRoute('/dashboard/settings')({
  loader: () => {
    const parentData = ???
  },
});
`
Was this page helpful?