TanStackT
TanStack12mo ago
6 replies
near-sapphire

Can I add custom information to RouteOptions?

I'm using TanStack Router with file-based routing and I'd like to dynamically generate my menu from the route tree. In order to do this, I need to have some extra metadata for each route (i.e. title, sort, etc.).

Is it possible to add some extra information when calling
createFileRoute
(or createLazyFileRoute) that I can then access from the route tree data from useRouter or similar?

Something like this, perhaps?
export const Route = createFileRoute('/')({
  component: Page,
  meta: { //<-- This is what I want
    title: "Home",
  },
})


I've looked all over and can't seem to find info dynamically generating the menu. Maybe I'm missing something or going about it the wrong way?
Was this page helpful?