To inject the DevTools middleware to the application, we currently have to wrap it with <SWRDevTools> when rendering. This is a great solution but not perfect due to the restrictions:
Users have to include SWRDevTools in their app bundle to debug production
The application will always run the SWRDevTools code (even if no SWRDevTools is installed)
It would be great to inject the middleware automatically to all SWR apps, from the extension side. So I opened https://github.com/vercel/swr/issues/2003 to discuss this idea. In extension’s content, we create the middleware and add it to __SWR_DEVTOOLS_USE__:
And then SWR will always use the middleware if defined.
The only thing is to make sure the injection runs before application code to avoid mismatching of number of hooks. I think "run_at": "document_start" already does that but not 100% sure.
To inject the DevTools middleware to the application, we currently have to wrap it with
<SWRDevTools>
when rendering. This is a great solution but not perfect due to the restrictions:It would be great to inject the middleware automatically to all SWR apps, from the extension side. So I opened https://github.com/vercel/swr/issues/2003 to discuss this idea. In extension’s content, we create the middleware and add it to
__SWR_DEVTOOLS_USE__
:And then SWR will always use the middleware if defined.
The only thing is to make sure the injection runs before application code to avoid mismatching of number of hooks. I think
"run_at": "document_start"
already does that but not 100% sure.