TanStackT
TanStack6mo ago
1 reply
conventional-black

Question about context propagation

Say we have structure like this,
routes/
    __root.tsx
    index.tsx
    $id/
        edit/
            index.tsx

I want to inject context from the root index.tsx (
/
) like this.
createFileRoute("/")({
  context: () => ({hello: "world"}),
})

I want to use that context in say, /1/edit/ with
const context = Route.useRouterContext()

But it seems I cannot access the context variable hello. Does context only propagates to child routes when injected in layouts?
Was this page helpful?