Skip to content

fix: useAppKitProvider not reactive to switchNetwork (#5453)#5654

Closed
rtomas wants to merge 1 commit into
mainfrom
rtomas/fix-provider-switch
Closed

fix: useAppKitProvider not reactive to switchNetwork (#5453)#5654
rtomas wants to merge 1 commit into
mainfrom
rtomas/fix-provider-switch

Conversation

@rtomas
Copy link
Copy Markdown
Contributor

@rtomas rtomas commented Apr 30, 2026

Description

useAppKitProvider (React + Vue) was not re-rendering after switchNetwork because the provider reference is intentionally shared across chains within a namespace, and the React hook only subscribed to ProviderController.state, while the Vue hook only subscribed via ProviderController.subscribe. Consumers wrapping the provider in chain-bound objects (e.g. ethers BrowserProvider, or any cached chain-bound helper) had no signal to reconstruct after a network switch. The fix adds a useSnapshot(ChainController.state) in the React hook and a ChainController.subscribeKey('activeCaipNetwork', ...) listener (with cleanup) in the Vue hook, so consumers re-render on switchNetwork even when the provider reference stays the same.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

closes #5453

Showcase (Optional)

N/A — DX-only fix, no UI change.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Subscribe to ChainController state in the React hook and add an
activeCaipNetwork subscribeKey listener in the Vue hook so consumers
re-render after switchNetwork even when the provider reference is
unchanged across chains within a namespace.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: d045bc1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@reown/appkit Patch
@reown/appkit-controllers Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-tron Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-universal-connector Patch
@reown/appkit-cdn Patch
@reown/appkit-experimental Patch
@reown/appkit-testing Patch
@reown/appkit-ui Patch
@reown/appkit-core Patch
@reown/appkit-utils Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet-button Patch
@reown/appkit-pay Patch
@reown/appkit-common Patch
@reown/appkit-polyfills Patch
@reown/appkit-wallet Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
appkit-demo Ready Ready Preview, Comment Apr 30, 2026 6:03pm
appkit-gallery Ready Ready Preview, Comment Apr 30, 2026 6:03pm
appkit-headless-sample-app Ready Ready Preview, Comment Apr 30, 2026 6:03pm
appkit-laboratory Ready Ready Preview, Comment Apr 30, 2026 6:03pm
9 Skipped Deployments
Project Deployment Actions Updated (UTC)
appkit-basic-example Ignored Ignored Apr 30, 2026 6:03pm
appkit-basic-sign-client-example Ignored Ignored Apr 30, 2026 6:03pm
appkit-basic-up-example Ignored Ignored Apr 30, 2026 6:03pm
appkit-ethers5-bera Ignored Ignored Apr 30, 2026 6:03pm
appkit-nansen-demo Ignored Ignored Apr 30, 2026 6:03pm
appkit-wagmi-cdn-example Ignored Ignored Apr 30, 2026 6:03pm
ethereum-provider-wagmi-example Ignored Ignored Apr 30, 2026 6:03pm
next-wagmi-solana-bitcoin-example Ignored Ignored Apr 30, 2026 6:03pm
vue-wagmi-example Ignored Ignored Apr 30, 2026 6:03pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

Visual Regression Test Results ✅ Passed

⚠️ 15 visual change(s) detected

Chromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=880
Storybook Preview: https://6493191bf4b10fed8ca7353f-hbxksnekxy.chromatic.com/

👉 Please review the visual changes in Chromatic and accept or reject them.

@github-actions
Copy link
Copy Markdown
Contributor

📦 Bundle Size Check

All bundles are within size limits

📊 View detailed bundle sizes

> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         75.72 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 212 ms   on Snapdragon 410
Total time:   1.7 s
@reown/appkit/react
Size limit:   235 kB
Size:         234.88 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 331 ms    on Snapdragon 410
Total time:   5 s
@reown/appkit/vue
Size limit:   80 kB
Size:         75.72 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 171 ms   on Snapdragon 410
Total time:   1.7 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         214.17 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 245 ms    on Snapdragon 410
Total time:   4.5 s
@reown/appkit-ui
Size limit:   500 kB
Size:         13.16 kB with all dependencies, minified and gzipped
Loading time: 258 ms   on slow 3G
Running time: 24 ms    on Snapdragon 410
Total time:   281 ms

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.48% 39736 / 50631
🔵 Statements 78.48% 39736 / 50631
🔵 Functions 76.31% 4256 / 5577
🔵 Branches 86.71% 9664 / 11145
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/appkit/src/library/vue/index.ts 27.35% 100% 28.57% 27.35% 96-130, 133-149, 152-167, 170-190, 193-208
packages/controllers/exports/react.ts 76.32% 87.91% 57.69% 76.32% 112-120, 137, 160, 561, 563-571, 588-589, 87-217, 229-310, 432-615
Generated in workflow #17075 for commit d045bc1 by the Vitest Coverage Report Action

@rtomas rtomas closed this Apr 30, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] walletProvider not updated after switching network (Solana Adapter)

1 participant