react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Docs]: Using Middleware in Data Mode requires module augmentation

Open silvenon opened this issue 2 months ago • 2 comments

Describe what's incorrect/missing in the documentation

This is not mentioned in the docs, but in order for context in loaders not to be any, the Future interface in react-router needs to be augmented:

declare module 'react-router' {
  interface Future {
    v8_middleware: true;
  }
}

I don't think there's a way around this, so my proposal is to add this to usage with Data Mode.

silvenon avatar Sep 16 '25 22:09 silvenon

I found that if I type my middleware functions as MiddlewareFunction<RouterContextProvider> it helps

dbergey avatar Sep 29 '25 17:09 dbergey

Unfortunately that doesn't help in my case, RouterContextProvider is already the default value.

silvenon avatar Oct 01 '25 11:10 silvenon