Skip to content

fix: read swr devtools on demand#4257

Open
SukkaW wants to merge 3 commits into
vercel:mainfrom
SukkaW:fix-swr-devtools-inject
Open

fix: read swr devtools on demand#4257
SukkaW wants to merge 3 commits into
vercel:mainfrom
SukkaW:fix-swr-devtools-inject

Conversation

@SukkaW
Copy link
Copy Markdown

@SukkaW SukkaW commented May 20, 2026

The PR fixes: koba04/swr-devtools#133

Due to Chrome extension limitation, the SWR DevTools may not inject window.__SWR_DEVTOOLS_USE__ fast enough (koba04/swr-devtools#133 (comment)), while SWR currently tries to read window.__SWR_DEVTOOLS_USE__ at the module level, which is way too early. By the time the SWR DevTools extension finally injects window.__SWR_DEVTOOLS_USE__, SWR already sets enableDevtools to false.

Here are the PR changes:

  • Now we always read window.__SWR_DEVTOOLS_USE__ on demand instead of pre-populated
  • We now expose window.__SWR_DEVTOOLS_SETUP__ to the SWR DevTools extension, in case the SWR devtools load too slow and miss the opportunity to grab the React instance.

cc @koba04 @shuding @promer94 @huozhi

@StephenSHorton
Copy link
Copy Markdown

The goat 🐐

@SukkaW SukkaW force-pushed the fix-swr-devtools-inject branch from 6929992 to 71b0812 Compare June 2, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SWR not detected?

2 participants