Skip to content

fix: lazy-load @reown/appkit to reduce initial bundle size#494

Merged
jannik-stacks merged 1 commit intomainfrom
fix/lazy-load-reown-appkit-squash
Feb 19, 2026
Merged

fix: lazy-load @reown/appkit to reduce initial bundle size#494
jannik-stacks merged 1 commit intomainfrom
fix/lazy-load-reown-appkit-squash

Conversation

@jannik-stacks
Copy link
Copy Markdown
Collaborator

@stacks/connect has two top-level imports from @reown/appkit-universal-connector
and @reown/appkit/networks. These cause consumer bundlers (Next.js, Webpack,
Vite) to eagerly resolve the entire @reown/appkit dependency tree — including
Lit UI components (@reown/appkit-ui, @reown/appkit-scaffold-ui, @reown/appkit-pay,
@reown/appkit-siwx) that @stacks/connect never renders — into the initial
JavaScript bundle. When bundled and minified, this adds ~1.7MB of JavaScript
that must be downloaded, parsed, and executed on every page load, even if
WalletConnect is never used. It also causes "Lit is in dev mode" warnings
during SSR.

Changes:
- request.ts: import → import type for UniversalConnectorConfig
  (type-only usage, erased at compile time)
- walletconnect/config.ts: inline Bitcoin CAIP network objects,
  removing import { bitcoin } from @reown/appkit/networks
- walletconnect/index.ts: dynamic import() for UniversalConnector
  inside the already-async initializeWalletConnectProvider
- tsup.config.ts: explicitly externalize @reown packages

The @reown/appkit code is now only loaded when a user actually clicks
WalletConnect — not on every page load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jannik-stacks jannik-stacks merged commit 8f729d1 into main Feb 19, 2026
6 checks passed
@jannik-stacks jannik-stacks deleted the fix/lazy-load-reown-appkit-squash branch February 19, 2026 19:34
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.

3 participants