fix: lazy-load @reown/appkit to reduce initial bundle size#494
Merged
jannik-stacks merged 1 commit intomainfrom Feb 19, 2026
Merged
fix: lazy-load @reown/appkit to reduce initial bundle size#494jannik-stacks merged 1 commit intomainfrom
jannik-stacks merged 1 commit intomainfrom
Conversation
Collaborator
jannik-stacks
commented
Feb 19, 2026
- closes fix: lazy-load @reown/appkit to reduce initial bundle size #492 (branch with signed commits)
@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>
heidar-stacks
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.